Package org.hibernate.mapping

Examples of org.hibernate.mapping.PersistentClass


    //yuk
    ReflectionManager reflectionManager = SearchFactoryImpl.getReflectionManager(cfg);
    //get the most specialized (ie subclass > superclass) non default index name
    //if none extract the name from the most generic (superclass > subclass) @Indexed class in the hierarchy
    //FIXME I'm inclined to get rid of the default value
    PersistentClass pc = cfg.getClassMapping( clazz.getName() );
    XClass rootIndex = null;
    do {
      XClass currentClazz = reflectionManager.toXClass( pc.getMappedClass() );
      Indexed indexAnn = currentClazz.getAnnotation( Indexed.class );
      if ( indexAnn != null ) {
        if ( indexAnn.index().length() != 0 ) {
          return indexAnn.index();
        }
        else {
          rootIndex = currentClazz;
        }
      }
      pc = pc.getSuperclass();
    }
    while ( pc != null );
    //there is nobody out there with a non default @Indexed.index
    if ( rootIndex != null ) {
      return rootIndex.getName();
View Full Code Here


  protected class OverrideMappings extends MappingsImpl {
    @SuppressWarnings("unchecked")
    @Override
    public void addClass(PersistentClass persistentClass) throws DuplicateMappingException {
      String entityName = persistentClass.getEntityName();
      PersistentClass old = (PersistentClass) classes.get(entityName);
      if (old == null) {
        classes.put(entityName, persistentClass);
      } else if (old.getMappedClass().isAssignableFrom(persistentClass.getMappedClass())) {
        classes.put(entityName, persistentClass);
        logger.info("{} override {} for entity configuration", persistentClass.getClassName(),
            old.getClassName());
      }
      classes.put(persistentClass.getMappedClass().getName(), (PersistentClass) classes.get(entityName));
    }
View Full Code Here

    Map<String, Set<FkSecondPass>> isADependencyOf = new HashMap<String, Set<FkSecondPass>>();
    List endOfQueueFkSecondPasses = new ArrayList( fkSecondPasses.size() );
    for ( FkSecondPass sp : fkSecondPasses ) {
      if ( sp.isInPrimaryKey() ) {
        String referenceEntityName = sp.getReferencedEntityName();
        PersistentClass classMapping = getClassMapping( referenceEntityName );
        String dependentTable = classMapping.getTable().getQuotedName();
        if ( !isADependencyOf.containsKey( dependentTable ) ) {
          isADependencyOf.put( dependentTable, new HashSet<FkSecondPass>() );
        }
        isADependencyOf.get( dependentTable ).add( sp );
      }
View Full Code Here

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

    public PersistentClass locatePersistentClassByEntityName(String entityName) {
      PersistentClass persistentClass = classes.get( entityName );
      if ( persistentClass == null ) {
        String actualEntityName = imports.get( entityName );
        if ( StringHelper.isNotEmpty( actualEntityName ) ) {
          persistentClass = classes.get( actualEntityName );
        }
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

    Map<String, Set<FkSecondPass>> isADependencyOf = new HashMap<String, Set<FkSecondPass>>();
    List<FkSecondPass> endOfQueueFkSecondPasses = new ArrayList<FkSecondPass>( fkSecondPasses.size() );
    for ( FkSecondPass sp : fkSecondPasses ) {
      if ( sp.isInPrimaryKey() ) {
        String referenceEntityName = sp.getReferencedEntityName();
        PersistentClass classMapping = getClassMapping( referenceEntityName );
        String dependentTable = classMapping.getTable().getQuotedName();
        if ( !isADependencyOf.containsKey( dependentTable ) ) {
          isADependencyOf.put( dependentTable, new HashSet<FkSecondPass>() );
        }
        isADependencyOf.get( dependentTable ).add( sp );
      }
View Full Code Here

    itr = propertyReferences.iterator();
    while ( itr.hasNext() ) {
      Mappings.PropertyReference upr = (Mappings.PropertyReference) itr.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

              fk.getTable().getName() +
              " does not specify the referenced entity"
            );
        }
                LOG.debugf("Resolving reference to class: %s", referencedEntityName);
        PersistentClass referencedClass = 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

      /**
       * Returns the identifier type of a mapped class
       */
      public Type getIdentifierType(String entityName) throws MappingException {
        PersistentClass pc = classes.get( entityName );
        if ( pc == null ) {
          throw new MappingException( "persistent class not known: " + entityName );
        }
        return pc.getIdentifier().getType();
      }

      public String getIdentifierPropertyName(String entityName) throws MappingException {
        final PersistentClass pc = classes.get( entityName );
        if ( pc == null ) {
          throw new MappingException( "persistent class not known: " + entityName );
        }
        if ( !pc.hasIdentifierProperty() ) {
          return null;
        }
        return pc.getIdentifierProperty().getName();
      }

      public Type getReferencedPropertyType(String entityName, String propertyName) throws MappingException {
        final PersistentClass pc = classes.get( entityName );
        if ( pc == null ) {
          throw new MappingException( "persistent class not known: " + entityName );
        }
        Property prop = pc.getReferencedProperty( propertyName );
        if ( prop == null ) {
          throw new MappingException(
              "property not known: " +
              entityName + '.' + propertyName
            );
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.