Tabnine Logo
Mappings.getClass
Code IndexAdd Tabnine to your IDE (free)

How to use
getClass
method
in
org.hibernate.cfg.Mappings

Best Java code snippets using org.hibernate.cfg.Mappings.getClass (Showing top 20 results out of 315)

origin: org.hibernate/com.springsource.org.hibernate

private static PersistentClass getSuperclass(Mappings mappings, Element subnode)
    throws MappingException {
  String extendsName = subnode.attributeValue( "extends" );
  PersistentClass superModel = mappings.getClass( extendsName );
  if ( superModel == null ) {
    String qualifiedExtendsName = getClassName( extendsName, mappings );
    superModel = mappings.getClass( qualifiedExtendsName );
  }
  if ( superModel == null ) {
    throw new MappingException( "Cannot extend unmapped class " + extendsName );
  }
  return superModel;
}
origin: org.hibernate/com.springsource.org.hibernate.core

private static PersistentClass getSuperclass(Mappings mappings, Element subnode)
    throws MappingException {
  String extendsName = subnode.attributeValue( "extends" );
  PersistentClass superModel = mappings.getClass( extendsName );
  if ( superModel == null ) {
    String qualifiedExtendsName = getClassName( extendsName, mappings );
    superModel = mappings.getClass( qualifiedExtendsName );
  }
  if ( superModel == null ) {
    throw new MappingException( "Cannot extend unmapped class " + extendsName );
  }
  return superModel;
}
origin: hibernate/hibernate

private static PersistentClass getSuperclass(Mappings mappings, Element subnode)
    throws MappingException {
  String superClass = getClassName( subnode.attributeValue( "extends" ), mappings );
  PersistentClass superModel = mappings.getClass( superClass );
  if ( superModel == null ) {
    throw new MappingException( "Cannot extend unmapped class " + superClass );
  }
  return superModel;
}
origin: org.hibernate/com.springsource.org.hibernate

@Override
public boolean isInPrimaryKey() {
  if ( entityClassName == null ) return false;
  final PersistentClass persistentClass = mappings.getClass( entityClassName );
  Property property = persistentClass.getIdentifierProperty();
  if ( path == null ) {
    return false;
  }
  else if ( property != null) {
    //try explicit identifier property
    return path.startsWith( property.getName() + "." );
  }
  else {
    //try the embedded property
    //embedded property starts their path with 'id.' See PropertyPreloadedData( ) use when idClass != null in AnnotationSourceProcessor
    if ( path.startsWith( "id." ) ) {
      KeyValue valueIdentifier = persistentClass.getIdentifier();
      String localPath = path.substring( 3 );
      if ( valueIdentifier instanceof Component ) {
        Iterator it = ( (Component) valueIdentifier ).getPropertyIterator();
        while ( it.hasNext() ) {
          Property idProperty = (Property) it.next();
          if ( localPath.startsWith( idProperty.getName() ) ) return true;
        }
      }
    }
  }
  return false;
}
origin: org.hibernate/com.springsource.org.hibernate.core

@Override
public boolean isInPrimaryKey() {
  if ( entityClassName == null ) return false;
  final PersistentClass persistentClass = mappings.getClass( entityClassName );
  Property property = persistentClass.getIdentifierProperty();
  if ( path == null ) {
    return false;
  }
  else if ( property != null) {
    //try explicit identifier property
    return path.startsWith( property.getName() + "." );
  }
  else {
    //try the embedded property
    //embedded property starts their path with 'id.' See PropertyPreloadedData( ) use when idClass != null in AnnotationSourceProcessor
    if ( path.startsWith( "id." ) ) {
      KeyValue valueIdentifier = persistentClass.getIdentifier();
      String localPath = path.substring( 3 );
      if ( valueIdentifier instanceof Component ) {
        Iterator it = ( (Component) valueIdentifier ).getPropertyIterator();
        while ( it.hasNext() ) {
          Property idProperty = (Property) it.next();
          if ( localPath.startsWith( idProperty.getName() ) ) return true;
        }
      }
    }
  }
  return false;
}
origin: hibernate/hibernate

Element element = (Element) iterator.next();
String superClass = getClassName( element.attributeValue( "extends" ), mappings );
if ( mappings.getClass( superClass ) == null ) {
  extendz.add( superClass );
origin: org.nakedobjects/nos-objectstore-hibernate

/**
 * Add all classes loaded in Naked Objects to the hibernate configuration
 */
public void configure(final Configuration cfg) {
  final Mappings mappings = cfg.createMappings();
  for (Iterator<PersistentNakedClass> iter = persistentClasses.getPersistentClasses(); iter.hasNext();) {
    final PersistentNakedClass persistentClass = iter.next();
    final String className = persistentClass.getName();
    if (mappings.getClass(className) == null) {
      LOG.debug("binding persistent class " + className);
      final Document doc4j = createDocument(persistentClass);
      org.w3c.dom.Document docW3c = createW3cDoc(doc4j);
      cfg.addDocument(docW3c);
      writeMappingDoc(doc4j, className);
    } else {
      LOG.info("class [" + className + "] is already mapped, skipping.. ");
    }
  }
}
origin: org.hibernate/com.springsource.org.hibernate

private static NativeSQLQueryRootReturn bindReturn(Element returnElem, Mappings mappings, int elementCount) {
  String alias = returnElem.attributeValue( "alias" );
  if( StringHelper.isEmpty( alias )) {
    alias = "alias_" + elementCount; // hack/workaround as sqlquery impl depend on having a key.
  }
  String entityName = HbmBinder.getEntityName(returnElem, mappings);
  if(entityName==null) {
    throw new MappingException( "<return alias='" + alias + "'> must specify either a class or entity-name");
  }
  LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );
  PersistentClass pc = mappings.getClass( entityName );
  java.util.Map propertyResults = bindPropertyResults(alias, returnElem, pc, mappings );
  return new NativeSQLQueryRootReturn(
      alias,
      entityName,
      propertyResults,
      lockMode
    );
}
origin: org.hibernate/com.springsource.org.hibernate.core

private static NativeSQLQueryRootReturn bindReturn(Element returnElem, Mappings mappings, int elementCount) {
  String alias = returnElem.attributeValue( "alias" );
  if( StringHelper.isEmpty( alias )) {
    alias = "alias_" + elementCount; // hack/workaround as sqlquery impl depend on having a key.
  }
  String entityName = HbmBinder.getEntityName(returnElem, mappings);
  if(entityName==null) {
    throw new MappingException( "<return alias='" + alias + "'> must specify either a class or entity-name");
  }
  LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );
  PersistentClass pc = mappings.getClass( entityName );
  java.util.Map propertyResults = bindPropertyResults(alias, returnElem, pc, mappings );
  return new NativeSQLQueryRootReturn(
      alias,
      entityName,
      propertyResults,
      lockMode
    );
}
origin: org.hibernate/com.springsource.org.hibernate.core

  public void doSecondPass(Map persistentClasses) throws MappingException {
    org.hibernate.mapping.FetchProfile profile = mappings.findOrCreateFetchProfile(
        fetchProfileName,
        MetadataSource.ANNOTATIONS
    );
    if ( MetadataSource.ANNOTATIONS != profile.getSource() ) {
      return;
    }

    PersistentClass clazz = mappings.getClass( fetch.entity().getName() );
    // throws MappingException in case the property does not exist
    clazz.getProperty( fetch.association() );

    profile.addFetch(
        fetch.entity().getName(), fetch.association(), fetch.mode().toString().toLowerCase()
    );
  }
}
origin: org.hibernate/com.springsource.org.hibernate

  public void doSecondPass(Map persistentClasses) throws MappingException {
    org.hibernate.mapping.FetchProfile profile = mappings.findOrCreateFetchProfile(
        fetchProfileName,
        MetadataSource.ANNOTATIONS
    );
    if ( MetadataSource.ANNOTATIONS != profile.getSource() ) {
      return;
    }

    PersistentClass clazz = mappings.getClass( fetch.entity().getName() );
    // throws MappingException in case the property does not exist
    clazz.getProperty( fetch.association() );

    profile.addFetch(
        fetch.entity().getName(), fetch.association(), fetch.mode().toString().toLowerCase()
    );
  }
}
origin: org.hibernate/com.springsource.org.hibernate

private static PersistentClass getSuperEntity(XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, Mappings mappings, InheritanceState inheritanceState) {
  InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity(
      clazzToProcess, inheritanceStatePerClass
  );
  PersistentClass superEntity = superEntityState != null ?
      mappings.getClass(
          superEntityState.getClazz().getName()
      ) :
      null;
  if ( superEntity == null ) {
    //check if superclass is not a potential persistent class
    if ( inheritanceState.hasParents() ) {
      throw new AssertionFailure(
          "Subclass has to be binded after it's mother class: "
              + superEntityState.getClazz().getName()
      );
    }
  }
  return superEntity;
}
origin: org.hibernate/com.springsource.org.hibernate.core

private void addMappedSuperClassInMetadata(PersistentClass persistentClass) {
  //add @MappedSuperclass in the metadata
  // classes from 0 to n-1 are @MappedSuperclass and should be linked
  org.hibernate.mapping.MappedSuperclass mappedSuperclass = null;
  final InheritanceState superEntityState =
      InheritanceState.getInheritanceStateOfSuperEntity( clazz, inheritanceStatePerClass );
  PersistentClass superEntity =
      superEntityState != null ?
          mappings.getClass( superEntityState.getClazz().getName() ) :
          null;
  final int lastMappedSuperclass = classesToProcessForMappedSuperclass.size() - 1;
  for ( int index = 0; index < lastMappedSuperclass; index++ ) {
    org.hibernate.mapping.MappedSuperclass parentSuperclass = mappedSuperclass;
    final Class<?> type = mappings.getReflectionManager()
        .toClass( classesToProcessForMappedSuperclass.get( index ) );
    //add MAppedSuperclass if not already there
    mappedSuperclass = mappings.getMappedSuperclass( type );
    if ( mappedSuperclass == null ) {
      mappedSuperclass = new org.hibernate.mapping.MappedSuperclass( parentSuperclass, superEntity );
      mappedSuperclass.setMappedClass( type );
      mappings.addMappedSuperclass( type, mappedSuperclass );
    }
  }
  if ( mappedSuperclass != null ) {
    persistentClass.setSuperMappedSuperclass( mappedSuperclass );
  }
}
origin: org.hibernate/com.springsource.org.hibernate

private void addMappedSuperClassInMetadata(PersistentClass persistentClass) {
  //add @MappedSuperclass in the metadata
  // classes from 0 to n-1 are @MappedSuperclass and should be linked
  org.hibernate.mapping.MappedSuperclass mappedSuperclass = null;
  final InheritanceState superEntityState =
      InheritanceState.getInheritanceStateOfSuperEntity( clazz, inheritanceStatePerClass );
  PersistentClass superEntity =
      superEntityState != null ?
          mappings.getClass( superEntityState.getClazz().getName() ) :
          null;
  final int lastMappedSuperclass = classesToProcessForMappedSuperclass.size() - 1;
  for ( int index = 0; index < lastMappedSuperclass; index++ ) {
    org.hibernate.mapping.MappedSuperclass parentSuperclass = mappedSuperclass;
    final Class<?> type = mappings.getReflectionManager()
        .toClass( classesToProcessForMappedSuperclass.get( index ) );
    //add MAppedSuperclass if not already there
    mappedSuperclass = mappings.getMappedSuperclass( type );
    if ( mappedSuperclass == null ) {
      mappedSuperclass = new org.hibernate.mapping.MappedSuperclass( parentSuperclass, superEntity );
      mappedSuperclass.setMappedClass( type );
      mappings.addMappedSuperclass( type, mappedSuperclass );
    }
  }
  if ( mappedSuperclass != null ) {
    persistentClass.setSuperMappedSuperclass( mappedSuperclass );
  }
}
origin: org.hibernate/com.springsource.org.hibernate.core

private static PersistentClass getSuperEntity(XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, Mappings mappings, InheritanceState inheritanceState) {
  InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity(
      clazzToProcess, inheritanceStatePerClass
  );
  PersistentClass superEntity = superEntityState != null ?
      mappings.getClass(
          superEntityState.getClazz().getName()
      ) :
      null;
  if ( superEntity == null ) {
    //check if superclass is not a potential persistent class
    if ( inheritanceState.hasParents() ) {
      throw new AssertionFailure(
          "Subclass has to be binded after it's mother class: "
              + superEntityState.getClazz().getName()
      );
    }
  }
  return superEntity;
}
origin: hibernate/hibernate

PersistentClass referenced = mappings.getClass( entityName );
IndexBackref ib = new IndexBackref();
ib.setName( '_' + node.attributeValue( "name" ) + "IndexBackref" );
origin: org.grails/grails-hibernate

if (mappings.getClass(domainClass.getFullName()) != null) {
  LOG.info("[GrailsDomainBinder] Class [" + domainClass.getFullName() + "] is already mapped, skipping.. ");
  return;
origin: org.hibernate/com.springsource.org.hibernate.core

PersistentClass referenced = mappings.getClass( entityName );
IndexBackref ib = new IndexBackref();
ib.setName( '_' + list.getOwnerEntityName() + "." + node.attributeValue( "name" ) + "IndexBackref" );
origin: org.grails/grails-datastore-gorm-hibernate-core

/**
 * Binds a unidirectional one-to-many creating a psuedo back reference property in the process.
 *
 * @param property
 * @param mappings
 * @param collection
 */
protected void bindUnidirectionalOneToMany(org.grails.datastore.mapping.model.types.OneToMany property, Mappings mappings, Collection collection) {
  Value v = collection.getElement();
  v.createForeignKey();
  String entityName;
  if (v instanceof ManyToOne) {
    ManyToOne manyToOne = (ManyToOne) v;
    entityName = manyToOne.getReferencedEntityName();
  } else {
    entityName = ((OneToMany) v).getReferencedEntityName();
  }
  collection.setInverse(false);
  PersistentClass referenced = mappings.getClass(entityName);
  Backref prop = new Backref();
  PersistentEntity owner = property.getOwner();
  prop.setEntityName(owner.getName());
  prop.setName(UNDERSCORE + addUnderscore(owner.getJavaClass().getSimpleName(), property.getName()) + "Backref");
  prop.setUpdateable(false);
  prop.setInsertable(true);
  prop.setCollectionRole(collection.getRole());
  prop.setValue(collection.getKey());
  prop.setOptional(true);
  referenced.addProperty(prop);
}
origin: org.grails/grails-hibernate

/**
 * Binds a unidirectional one-to-many creating a psuedo back reference property in the process.
 *
 * @param property
 * @param mappings
 * @param collection
 */
private static void bindUnidirectionalOneToMany(GrailsDomainClassProperty property, Mappings mappings, Collection collection) {
  Value v = collection.getElement();
  v.createForeignKey();
  String entityName;
  if (v instanceof ManyToOne) {
    ManyToOne manyToOne = (ManyToOne) v;
    entityName = manyToOne.getReferencedEntityName();
  } else {
    entityName = ((OneToMany) v).getReferencedEntityName();
  }
  collection.setInverse(false);
  PersistentClass referenced = mappings.getClass(entityName);
  Backref prop = new Backref();
  prop.setEntityName(property.getDomainClass().getFullName());
  prop.setName(UNDERSCORE + addUnderscore(property.getDomainClass().getShortName(), property.getName()) + "Backref");
  prop.setUpdateable(false);
  prop.setInsertable(true);
  prop.setCollectionRole(collection.getRole());
  prop.setValue(collection.getKey());
  prop.setOptional(true);
  referenced.addProperty(prop);
}
org.hibernate.cfgMappingsgetClass

Javadoc

Retrieves the entity mapping metadata for the given entity name.

Popular methods of Mappings

  • addClass
    Add entity mapping metadata.
  • addImport
    Adds an import (HQL entity rename) to the repository.
  • addTable
    Adds table metadata to this repository returning the created metadata instance.
  • getCatalogName
    Returns the currently bound default catalog name.
  • getSchemaName
    Returns the currently bound default schema name.
  • addCollection
    Add collection mapping metadata to this repository.
  • addSecondPass
    Adds a second pass.
  • addTableBinding
    Adds a table binding to this repository.
  • getDefaultAccess
    Get the current default property access style.
  • isAutoImport
    Determine whether auto importing of entity names is currently enabled.
  • addDenormalizedTable
    Adds a 'denormalized table' to this repository.
  • addFilterDefinition
    Adds a filter definition to this repository.
  • addDenormalizedTable,
  • addFilterDefinition,
  • addTypeDef,
  • addUniquePropertyReference,
  • getObjectNameNormalizer,
  • setAutoImport,
  • addColumnBinding,
  • addPropertyReference,
  • addQuery

Popular in Java

  • Running tasks concurrently on multiple threads
  • runOnUiThread (Activity)
  • getResourceAsStream (ClassLoader)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now