Codota Logo
ClassMetadata.getMappedClass
Code IndexAdd Codota to your IDE (free)

How to use
getMappedClass
method
in
org.hibernate.metadata.ClassMetadata

Best Java code snippets using org.hibernate.metadata.ClassMetadata.getMappedClass (Showing top 20 results out of 315)

  • Common ways to obtain ClassMetadata
private void myMethod () {
ClassMetadata c =
  • Codota IconSessionFactory sessionFactory;Class entityClass;sessionFactory.getClassMetadata(entityClass)
  • Codota IconSessionFactory sessionFactory;String entityName;sessionFactory.getClassMetadata(entityName)
  • Codota IconSessionFactory sessionFactory;Object object;sessionFactory.getClassMetadata(object.getClass())
  • Smart code suggestions by Codota
}
origin: BroadleafCommerce/BroadleafCommerce

protected void populateCaches(String targetMode, Map<String, Object> managerMap) {
  final EntityManager em = getEntityManager(managerMap);
  final PlatformTransactionManager txManager = getTransactionManager(managerMap);
  final EJB3ConfigurationDao ejb3ConfigurationDao = getEJB3ConfigurationDao(managerMap);
  SessionFactory sessionFactory = em.unwrap(Session.class).getSessionFactory();
  for (Object item : sessionFactory.getAllClassMetadata().values()) {
    ClassMetadata metadata = (ClassMetadata) item;
    Class<?> mappedClass = metadata.getMappedClass();
    String managerCacheKey = buildManagerCacheKey(targetMode, mappedClass);
    ENTITY_MANAGER_CACHE.put(managerCacheKey, em);
    TRANSACTION_MANAGER_CACHE.put(managerCacheKey, txManager);
    String ejb3ConfigDaoCacheKey = buildEJB3ConfigDaoCacheKey(mappedClass);
    if (!EJB3_CONFIG_DAO_CACHE.containsKey(ejb3ConfigDaoCacheKey)) {
      EJB3_CONFIG_DAO_CACHE.put(ejb3ConfigDaoCacheKey, ejb3ConfigurationDao);
    }
  }
}
origin: BroadleafCommerce/BroadleafCommerce

for (Object item : sessionFactory.getAllClassMetadata().values()) {
  ClassMetadata metadata = (ClassMetadata) item;
  Class<?> mappedClass = metadata.getMappedClass();
  if (mappedClass != null && ceilingClass.isAssignableFrom(mappedClass)) {
    entities.add(mappedClass);
origin: BroadleafCommerce/BroadleafCommerce

ClassMetadata metadata = (ClassMetadata) item;
String idProperty = metadata.getIdentifierPropertyName();
Class<?> mappedClass = metadata.getMappedClass();
Field idField;
try {
origin: my2iu/Jinq

public MetamodelUtilFromSessionFactory(SessionFactory factory)
{
 // Go through all the entities 
 for (String entityClassName: factory.getAllClassMetadata().keySet())
 {
   ClassMetadata entityData = factory.getClassMetadata(entityClassName);
   classToEntityName.put(entityData.getMappedClass(), entityData.getEntityName());
   classNameToEntityName.put(entityClassName, entityData.getEntityName());
   //System.out.println(entityClassName + " " + entityData.getMappedClass().getCanonicalName() + " " + entityData.getEntityName());
   // TODO: It turns out all three values are the same, but I think it's ok for now.
      scanClassMetadata(entityData);
 }
}
origin: openmrs/openmrs-core

Class<?> entityClass = classMetadata.getMappedClass();
if (Order.class.equals(entityClass)) {
origin: my2iu/Jinq

private void scanClassMetadata(ClassMetadata meta)
{
 Class<?> entityClass = meta.getMappedClass();
 String[] names = meta.getPropertyNames();
 Type[] types = meta.getPropertyTypes();
 for (int n = 0; n < names.length; n++)
 {
   String fieldName = names[n];
   Type type = types[n];
   registerEntityField(entityClass, fieldName, type);
 }
 if (meta.getIdentifierPropertyName() != null)
   registerEntityField(entityClass, meta.getIdentifierPropertyName(), meta.getIdentifierType());
 
 //System.out.println(names + " " + types);
}

origin: com.atlassian.hibernate/hibernate.adapter

@Override
public Class getMappedClass() {
  return metadata.getMappedClass();
}
origin: ldlqdsdcn/eidea4

public Class<?> getJavaClass() {
  return metadata.getMappedClass();
}
origin: org.hibernatespatial/hibernate-spatial

private FeatureInvocationHandler(Object o, ClassMetadata meta) {
  //TODO check if this is sufficiently general. What if not a POJO?
  if (meta.getMappedClass(EntityMode.POJO) != o.getClass()) {
    throw new RuntimeException("Metadata and POJO class do not cohere");
  }
  this.target = o;
  this.metadata = meta;
}
origin: com.github.jknack/mwa-jpa

@Override
protected Class<?> getClassForName(final String name) throws ClassNotFoundException {
 Collection<ClassMetadata> classes = metadata.values();
 for (ClassMetadata classMetadata : classes) {
  Class<?> mappedClass = classMetadata.getMappedClass();
  if (name.equals(mappedClass.getSimpleName())) {
   return mappedClass;
  }
 }
 return super.getClassForName(name);
}
origin: stackoverflow.com

 public <T> Class<? extends T> findEntityClassForEntityInterface(
  SessionFactory sessionFactory, 
  Class<T> entityInterface
) {
  for (ClassMetadata metadata : sessionFactory.getAllClassMetadata().values()) {
    Class entityClass = metadata.getMappedClass(EntityMode.POJO);
    if (entityInterface.isAssignableFrom(entityClass)) {
      return entityClass;
    }
  }
  return null;
}
origin: yahoo/elide

@Override
public void populateEntityDictionary(EntityDictionary dictionary) {
  /* bind all entities */
  for (ClassMetadata meta : sessionFactory.getAllClassMetadata().values()) {
    dictionary.bindEntity(meta.getMappedClass(EntityMode.POJO));
  }
}
origin: riotfamily/riot

private ClassMetadata getIndexClassMetadata(String ownerClassName) {
  if (metaDataMap.containsKey(ownerClassName)) {
    return metaDataMap.get(ownerClassName);
  }
  String indexClassName = ownerClassName  + "ContentIndex";
  ClassMetadata meta = sessionFactory.getClassMetadata(indexClassName);
  if (meta != null) {
    Class<?> indexClass = meta.getMappedClass();
    if (ContentIndex.class.isAssignableFrom(indexClass)) {
      Filter filter = indexClass.getAnnotation(Filter.class);
      Assert.isTrue(filter != null && filter.name().equals("contentIndex"),
          String.format("%s must be annotated with @Filter(name=\"contentIndex\")",
          indexClass.getName()));
    }
    else {
      meta = null;
      log.warn("Class {} matches the naming convention for content " +
          "indexes but does not extend ContentIndex.", indexClass);
    }
  }
  metaDataMap.put(ownerClassName, meta);
  return meta;
}
origin: org.hibernatespatial/hibernate-spatial

private Method getGetterFor(String property) {
  Class cl = this.metadata.getMappedClass(EntityMode.POJO);
  Getter getter = ReflectHelper.getGetter(cl, property);
  return getter.getMethod();
}
origin: org.grails/grails-hibernate

public static void configureHibernateDomainClasses(SessionFactory sessionFactory,
    String sessionFactoryName, GrailsApplication application) {
  Map<String, GrailsDomainClass> hibernateDomainClassMap = new HashMap<String, GrailsDomainClass>();
  for (Object o : sessionFactory.getAllClassMetadata().values()) {
    ClassMetadata classMetadata = (ClassMetadata) o;
    configureDomainClass(sessionFactory, sessionFactoryName, application, classMetadata,
        classMetadata.getMappedClass(EntityMode.POJO),
        hibernateDomainClassMap);
  }
  configureInheritanceMappings(hibernateDomainClassMap);
}
origin: riotfamily/riot

@SuppressWarnings("unchecked")
public void postProcessConfiguration(Configuration config)
    throws IOException, TemplateException {
  
  TemplateHashModel statics = getBeansWrapper(config).getStaticModels();
  Collection<ClassMetadata> allMetadata = sessionFactory.getAllClassMetadata().values();
  for (ClassMetadata meta : allMetadata) {
    Class<?> mappedClass = meta.getMappedClass();
    if (ActiveRecord.class.isAssignableFrom(mappedClass)) {
      String key = ClassUtils.getShortName(mappedClass);
      if (config.getSharedVariable(key) != null) {
        log.warn("Another shared variable with the name '{}'" +
            " already exist. Use statics[\"{}\"] in your" +
            " FreeMarker templates to access the static" +
            " methods of your ActiveRecord class.", 
            key, mappedClass.getName());
      }
      else {
        TemplateModel tm = statics.get(mappedClass.getName());
        config.setSharedVariable(key, tm);
      }
    }
  }
}
origin: com.atlassian.hibernate/hibernate.adapter

@Override
@SuppressWarnings("deprecation")
public Map getAllClassMetadata() throws HibernateException {
  try {
    final Map<Class, ClassMetadata> map = new HashMap<>();
    for (String entityName : getSessionFactoryV5().getMetamodel().getAllEntityNames()) {
      org.hibernate.metadata.ClassMetadata metadata = getSessionFactoryV5().getClassMetadata(entityName);
      map.put(metadata.getMappedClass(), ClassMetadataV2Adapter.adapt(metadata, getSessionFactoryV5(), null));
    }
    return map;
  } catch (final PersistenceException ex) {
    throw HibernateExceptionAdapter.adapt(ex);
  }
}
origin: riotfamily/riot

public static References getReferencingClasses(SessionFactory sessionFactory, Class<?> clazz) {
  References references = new References(); 
  for (Map.Entry<String, ClassMetadata> entry: sessionFactory.getAllClassMetadata().entrySet()) {
    Class<?> mappedClass = entry.getValue().getMappedClass();
    for (String propertyName: entry.getValue().getPropertyNames()) {
      Type t = entry.getValue().getPropertyType(propertyName);
      if (t instanceof EntityType) {
        EntityType entityType=(EntityType) t;
        if (entityType.getAssociatedEntityName().equals(clazz.getName())) {
          references.addEntityReference(propertyName, mappedClass);
        }
      }
      else if (t.isCollectionType()) {
        CollectionType cType = (CollectionType) t;
        QueryableCollection collectionPersister = (QueryableCollection) ((SessionFactoryImplementor) sessionFactory).getCollectionPersister( cType.getRole());
        if (collectionPersister.getElementType().isEntityType() && collectionPersister.getElementPersister().getEntityName().equals(clazz.getName())) {
          references.addCollectionReference(propertyName, mappedClass);
        }
        
      }
    }
  }
  return references;
}

origin: org.apache.tapestry/tapestry-hibernate

/**
 * Contributes {@link ApplicationStateContribution}s for all registered Hibernate entity classes.
 *
 * @param configuration
 *         Configuration to contribute
 * @param entitySessionStatePersistenceStrategyEnabled
 *         indicates if contribution should take place
 * @param sessionSource
 *         creates Hibernate session
 */
public static void contributeApplicationStateManager(
    MappedConfiguration<Class, ApplicationStateContribution> configuration,
    @Symbol(HibernateSymbols.ENTITY_SESSION_STATE_PERSISTENCE_STRATEGY_ENABLED)
    boolean entitySessionStatePersistenceStrategyEnabled, HibernateSessionSource sessionSource)
{
  if (!entitySessionStatePersistenceStrategyEnabled)
    return;
  for (ClassMetadata classMetadata : sessionSource.getSessionFactory().getAllClassMetadata().values())
  {
    final Class entityClass = classMetadata.getMappedClass();
    configuration.add(entityClass, new ApplicationStateContribution(HibernatePersistenceConstants.ENTITY));
  }
}
origin: org.grails/grails-hibernate

@Override
public void destroy() throws HibernateException {
  if (grailsApplication.isWarDeployed()) {
    MetaClassRegistry registry = GroovySystem.getMetaClassRegistry();
    Map<?, ?> classMetaData = getSessionFactory().getAllClassMetadata();
    for (Object o : classMetaData.values()) {
      ClassMetadata classMetadata = (ClassMetadata) o;
      Class<?> mappedClass = classMetadata.getMappedClass(EntityMode.POJO);
      registry.removeMetaClass(mappedClass);
    }
  }
  try {
    super.destroy();
  } catch (HibernateException e) {
    if (e.getCause() instanceof NameNotFoundException) {
      LOG.debug(e.getCause().getMessage(), e);
    }
    else {
      throw e;
    }
  }
}
org.hibernate.metadataClassMetadatagetMappedClass

Javadoc

The persistent class, or null

Popular methods of ClassMetadata

  • getIdentifierPropertyName
    Get the name of the identifier property (or return null)
  • getIdentifierType
    Get the identifier Hibernate type
  • getEntityName
    The name of the entity
  • getPropertyNames
    Get the names of the class' persistent properties
  • getIdentifier
  • getPropertyType
    Get the type of a particular (named) property
  • getPropertyTypes
    Get the Hibernate types of the class properties
  • getPropertyValue
    Get the value of a particular (named) property
  • getPropertyValues
    Extract the property values from the given entity.
  • hasIdentifierProperty
    Does this class have an identifier property?
  • setPropertyValue
    Set the value of a particular (named) property
  • instantiate
  • setPropertyValue,
  • instantiate,
  • getVersionProperty,
  • setIdentifier,
  • getPropertyNullability,
  • getVersion,
  • isVersioned,
  • getNaturalIdentifierProperties,
  • getPropertyLaziness

Popular in Java

  • Making http post requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • onCreateOptionsMenu (Activity)
  • InputStreamReader (java.io)
    An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes
  • MalformedURLException (java.net)
    Thrown to indicate that a malformed URL has occurred. Either no legal protocol could be found in a s
  • ArrayList (java.util)
    Resizable-array implementation of the List interface. Implements all optional list operations, and p
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • TimerTask (java.util)
    A task that can be scheduled for one-time or repeated execution by a Timer.
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now