Package org.hibernate.mapping

Examples of org.hibernate.mapping.PersistentClass


public abstract class EntityModelDetector extends Detector {

  public void visit(Configuration cfg, IssueCollector collector) {
    for (Iterator iter = cfg.getClassMappings(); iter.hasNext();) {
      PersistentClass clazz = (PersistentClass) iter.next();
      this.visit(cfg, clazz, collector);       
    }
  }
View Full Code Here


      if(col.getCacheConcurrencyStrategy()!=null) { // caching is enabled
        if (!col.getElement().isSimpleValue()) {
          String entityName = (String) col.getElement().accept( new EntityNameFromValueVisitor() );

          if(entityName!=null) {
            PersistentClass classMapping = configuration.getClassMapping( entityName );
            if(classMapping.getCacheConcurrencyStrategy()==null) {
              collector.reportIssue( new Issue("CACHE_COLLECTION_NONCACHABLE_TARGET", Issue.HIGH_PRIORITY, "Entity '" + classMapping.getEntityName() +"' is referenced from the cache-enabled collection '" + col.getRole() + "' without the entity being cachable"));
            }
          }
        }
      }
    } 
View Full Code Here

  public String getTag(PersistentClass pc) {
    return (String) pc.accept(HBMTagForPersistentClassVisitor.INSTANCE);
  }

  public String getTag(Property property) {
    PersistentClass persistentClass = property.getPersistentClass();
    if(persistentClass!=null) {
      if(persistentClass.getVersion()==property) {
        String typeName = ((SimpleValue)property.getValue()).getTypeName();
        if("timestamp".equals(typeName) || "dbtimestamp".equals(typeName)) {
          return "timestamp";
        } else {
          return "version";
View Full Code Here

    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,
View Full Code Here

          Component comp = (Component) value;
          parentPropIter = comp.getPropertyIterator();
        }
        else if ( value instanceof ToOne ) {
          ToOne toOne = (ToOne) value;
          PersistentClass referencedPc = mappings.getClass( toOne.getReferencedEntityName() );
          if ( toOne.getReferencedPropertyName() != null ) {
            try {
              parentPropIter = ( (Component) referencedPc.getRecursiveProperty( toOne.getReferencedPropertyName() ).getValue() ).getPropertyIterator();
            } catch (ClassCastException e) {
              throw new MappingException("dotted notation reference neither a component nor a many/one to one", e);
            }
          }
          else {
            try {
              if ( referencedPc.getIdentifierMapper() == null ) {
                parentPropIter = ( (Component) referencedPc.getIdentifierProperty().getValue() ).getPropertyIterator();
              }
              else {
                parentPropIter = referencedPc.getIdentifierMapper().getPropertyIterator();
              }
            }
            catch (ClassCastException e) {
              throw new MappingException("dotted notation reference neither a component nor a many/one to one", e);
            }
View Full Code Here

    deleteCallable = new boolean[tableSpan];
    insertResultCheckStyles = new ExecuteUpdateResultCheckStyle[tableSpan];
    updateResultCheckStyles = new ExecuteUpdateResultCheckStyle[tableSpan];
    deleteResultCheckStyles = new ExecuteUpdateResultCheckStyle[tableSpan];

    PersistentClass pc = persistentClass;
    int jk = tableSpan-1;
    while (pc!=null) {
      customSQLInsert[jk] = pc.getCustomSQLInsert();
      insertCallable[jk] = customSQLInsert[jk] != null && pc.isCustomInsertCallable();
      insertResultCheckStyles[jk] = pc.getCustomSQLInsertCheckStyle() == null
                                    ? ExecuteUpdateResultCheckStyle.determineDefault( customSQLInsert[jk], insertCallable[jk] )
                                      : pc.getCustomSQLInsertCheckStyle();
      customSQLUpdate[jk] = pc.getCustomSQLUpdate();
      updateCallable[jk] = customSQLUpdate[jk] != null && pc.isCustomUpdateCallable();
      updateResultCheckStyles[jk] = pc.getCustomSQLUpdateCheckStyle() == null
                                    ? ExecuteUpdateResultCheckStyle.determineDefault( customSQLUpdate[jk], updateCallable[jk] )
                                      : pc.getCustomSQLUpdateCheckStyle();
      customSQLDelete[jk] = pc.getCustomSQLDelete();
      deleteCallable[jk] = customSQLDelete[jk] != null && pc.isCustomDeleteCallable();
      deleteResultCheckStyles[jk] = pc.getCustomSQLDeleteCheckStyle() == null
                                    ? ExecuteUpdateResultCheckStyle.determineDefault( customSQLDelete[jk], deleteCallable[jk] )
                                      : pc.getCustomSQLDeleteCheckStyle();
      jk--;
      pc = pc.getSuperclass();
    }
    if ( jk != -1 ) {
      throw new AssertionFailure( "Tablespan does not match height of joined-subclass hiearchy." );
    }
View Full Code Here

    public PersistentClass getClass(String entityName) {
      return ( PersistentClass ) classes.get( entityName );
    }

    public PersistentClass locatePersistentClassByEntityName(String entityName) {
      PersistentClass persistentClass = ( PersistentClass ) classes.get( entityName );
      if ( persistentClass == null ) {
        String actualEntityName = ( String ) imports.get( entityName );
        if ( StringHelper.isNotEmpty( actualEntityName ) ) {
          persistentClass = ( PersistentClass ) classes.get( actualEntityName );
        }
View Full Code Here

    String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
    String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );

    Iterator iter = classes.values().iterator();
    while ( iter.hasNext() ) {
      PersistentClass pc = ( PersistentClass ) iter.next();
      if ( !pc.isInherited() ) {
        IdentifierGenerator ig = pc.getIdentifier().createIdentifierGenerator(
            getIdentifierGeneratorFactory(),
            dialect,
            defaultCatalog,
            defaultSchema,
            (RootClass) pc
View Full Code Here

    iter = propertyReferences.iterator();
    while ( iter.hasNext() ) {
      Mappings.PropertyReference upr = (Mappings.PropertyReference) iter.next();

      PersistentClass clazz = getClassMapping( upr.referencedClass );
      if ( clazz == null ) {
        throw new MappingException(
            "property-ref to unmapped class: " +
            upr.referencedClass
          );
      }

      Property prop = clazz.getReferencedProperty( upr.propertyName );
      if ( upr.unique ) {
        ( (SimpleValue) prop.getValue() ).setAlternateUniqueKey( true );
      }
    }
View Full Code Here

            );
        }
        if ( log.isDebugEnabled() ) {
          log.debug( "resolving reference to class: " + referencedEntityName );
        }
        PersistentClass referencedClass = (PersistentClass) classes.get( referencedEntityName );
        if ( referencedClass == null ) {
          throw new MappingException(
              "An association from the table " +
              fk.getTable().getName() +
              " refers to an unmapped class: " +
              referencedEntityName
            );
        }
        if ( referencedClass.isJoinedSubclass() ) {
          secondPassCompileForeignKeys( referencedClass.getSuperclass().getTable(), done );
        }
        fk.setReferencedTable( referencedClass.getTable() );
        fk.alignColumns();
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.hibernate.mapping.PersistentClass

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.