Package org.hibernate.mapping

Examples of org.hibernate.mapping.PersistentClass


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

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

      public Type getReferencedPropertyType(String persistentClass, String propertyName) throws MappingException {
        final PersistentClass pc = (PersistentClass) classes.get( persistentClass );
        if ( pc == null ) {
          throw new MappingException( "persistent class not known: " + persistentClass );
        }
        Property prop = pc.getReferencedProperty( propertyName );
        if ( prop == null ) {
          throw new MappingException(
              "property not known: " +
              persistentClass + '.' + propertyName
            );
View Full Code Here


    if ( persistentClass.hasPojoRepresentation() ) {
      entityNameByInheritenceClassMap.put( persistentClass.getMappedClass(), persistentClass.getEntityName() );
      iter = persistentClass.getSubclassIterator();
      while ( iter.hasNext() ) {
        final PersistentClass pc = ( PersistentClass ) iter.next();
        entityNameByInheritenceClassMap.put( pc.getMappedClass(), pc.getEntityName() );
      }
    }

    tuplizerMapping = new EntityEntityModeToTuplizerMapping( persistentClass, this );
  }
View Full Code Here

  Dom4jEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity) {
    super( entityMetamodel, mappedEntity );
    inheritenceNodeNameMap.put( mappedEntity.getNodeName(), mappedEntity.getEntityName() );
    Iterator itr = mappedEntity.getSubclassClosureIterator();
    while( itr.hasNext() ) {
      final PersistentClass mapping = ( PersistentClass ) itr.next();
      inheritenceNodeNameMap.put( mapping.getNodeName(), mapping.getEntityName() );
    }
  }
View Full Code Here

    //Generators:

    identifierGenerators = new HashMap();
    Iterator classes = cfg.getClassMappings();
    while ( classes.hasNext() ) {
      PersistentClass model = (PersistentClass) classes.next();
      if ( !model.isInherited() ) {
        IdentifierGenerator generator = model.getIdentifier().createIdentifierGenerator(
            settings.getDialect(),
                settings.getDefaultCatalogName(),
                settings.getDefaultSchemaName(),
                (RootClass) model
          );
        identifierGenerators.put( model.getEntityName(), generator );
      }
    }


    ///////////////////////////////////////////////////////////////////////
    // Prepare persisters and link them up with their cache
    // region/access-strategy

    final String cacheRegionPrefix = settings.getCacheRegionPrefix() == null ? "" : settings.getCacheRegionPrefix() + ".";

    entityPersisters = new HashMap();
    Map entityAccessStrategies = new HashMap();
    Map classMeta = new HashMap();
    classes = cfg.getClassMappings();
    while ( classes.hasNext() ) {
      final PersistentClass model = (PersistentClass) classes.next();
      model.prepareTemporaryTables( mapping, settings.getDialect() );
      final String cacheRegionName = cacheRegionPrefix + model.getRootClass().getCacheRegionName();
      // cache region is defined by the root-class in the hierarchy...
      EntityRegionAccessStrategy accessStrategy = ( EntityRegionAccessStrategy ) entityAccessStrategies.get( cacheRegionName );
      if ( accessStrategy == null && settings.isSecondLevelCacheEnabled() ) {
        final AccessType accessType = AccessType.parse( model.getCacheConcurrencyStrategy() );
        if ( accessType != null ) {
          log.trace( "Building cache for entity data [" + model.getEntityName() + "]" );
          EntityRegion entityRegion = settings.getRegionFactory().buildEntityRegion( cacheRegionName, properties, CacheDataDescriptionImpl.decode( model ) );
          accessStrategy = entityRegion.buildAccessStrategy( accessType );
          entityAccessStrategies.put( cacheRegionName, accessStrategy );
          allCacheRegions.put( cacheRegionName, entityRegion );
        }
      }
      EntityPersister cp = PersisterFactory.createClassPersister( model, accessStrategy, this, mapping );
      entityPersisters.put( model.getEntityName(), cp );
      classMeta.put( model.getEntityName(), cp.getClassMetadata() );
    }
    classMetadata = Collections.unmodifiableMap(classMeta);

    Map tmpEntityToCollectionRoleMap = new HashMap();
    collectionPersisters = new HashMap();
    Iterator collections = cfg.getCollectionMappings();
    while ( collections.hasNext() ) {
      Collection model = (Collection) collections.next();
      final String cacheRegionName = cacheRegionPrefix + model.getCacheRegionName();
      final AccessType accessType = AccessType.parse( model.getCacheConcurrencyStrategy() );
      CollectionRegionAccessStrategy accessStrategy = null;
      if ( accessType != null && settings.isSecondLevelCacheEnabled() ) {
        log.trace( "Building cache for collection data [" + model.getRole() + "]" );
        CollectionRegion collectionRegion = settings.getRegionFactory().buildCollectionRegion( cacheRegionName, properties, CacheDataDescriptionImpl.decode( model ) );
        accessStrategy = collectionRegion.buildAccessStrategy( accessType );
        entityAccessStrategies.put( cacheRegionName, accessStrategy );
        allCacheRegions.put( cacheRegionName, collectionRegion );
      }
      CollectionPersister persister = PersisterFactory.createCollectionPersister( cfg, model, accessStrategy, this) ;
      collectionPersisters.put( model.getRole(), persister.getCollectionMetadata() );
      Type indexType = persister.getIndexType();
      if ( indexType != null && indexType.isAssociationType() && !indexType.isAnyType() ) {
        String entityName = ( ( AssociationType ) indexType ).getAssociatedEntityName( this );
        Set roles = ( Set ) tmpEntityToCollectionRoleMap.get( entityName );
        if ( roles == null ) {
View Full Code Here

  // todo : move this to SF per HHH-3517; also see HHH-1907 and ComponentMetamodel
  private ComponentTuplizerFactory componentTuplizerFactory = new ComponentTuplizerFactory();

  public ComponentEntityModeToTuplizerMapping(Component component) {
    PersistentClass owner = component.getOwner();

    // create our own copy of the user-supplied tuplizer impl map
    Map userSuppliedTuplizerImpls = new HashMap();
    if ( component.getTuplizerMap() != null ) {
      userSuppliedTuplizerImpls.putAll( component.getTuplizerMap() );
    }

    // Build the dynamic-map tuplizer...
    Tuplizer dynamicMapTuplizer;
    String tuplizerClassName = ( String ) userSuppliedTuplizerImpls.remove( EntityMode.MAP );
    if ( tuplizerClassName == null ) {
      dynamicMapTuplizer = componentTuplizerFactory.constructDefaultTuplizer( EntityMode.MAP, component );
    }
    else {
      dynamicMapTuplizer = componentTuplizerFactory.constructTuplizer( tuplizerClassName, component );
    }

    // then the pojo tuplizer, using the dynamic-map tuplizer if no pojo representation is available
    tuplizerClassName = ( String ) userSuppliedTuplizerImpls.remove( EntityMode.POJO );
    Tuplizer pojoTuplizer;
    if ( owner.hasPojoRepresentation() && component.hasPojoRepresentation() ) {
      if ( tuplizerClassName == null ) {
        pojoTuplizer = componentTuplizerFactory.constructDefaultTuplizer( EntityMode.POJO, component );
      }
      else {
        pojoTuplizer = componentTuplizerFactory.constructTuplizer( tuplizerClassName, component );
      }
    }
    else {
      pojoTuplizer = dynamicMapTuplizer;
    }

    // then dom4j tuplizer, if dom4j representation is available
    Tuplizer dom4jTuplizer;
    tuplizerClassName = ( String ) userSuppliedTuplizerImpls.remove( EntityMode.DOM4J );
    if ( owner.hasDom4jRepresentation() ) {
      if ( tuplizerClassName == null ) {
        dom4jTuplizer = componentTuplizerFactory.constructDefaultTuplizer( EntityMode.DOM4J, component );
      }
      else {
        dom4jTuplizer = componentTuplizerFactory.constructTuplizer( tuplizerClassName, component );
View Full Code Here

    isInstanceNodeNames.add( nodeName );

    if ( mappingInfo.hasSubclasses() ) {
      Iterator itr = mappingInfo.getSubclassClosureIterator();
      while ( itr.hasNext() ) {
        final PersistentClass subclassInfo = ( PersistentClass ) itr.next();
        isInstanceNodeNames.add( subclassInfo.getNodeName() );
      }
    }
  }
View Full Code Here

    isInstanceNodeNames.add( nodeName );

    if ( mappingInfo.hasSubclasses() ) {
      Iterator itr = mappingInfo.getSubclassClosureIterator();
      while ( itr.hasNext() ) {
        final PersistentClass subclassInfo = ( PersistentClass ) itr.next();
        isInstanceNodeNames.add( subclassInfo.getNodeName() );
      }
    }
  }
View Full Code Here

      Iterator<PersistentClass> persistentClasses,
      SessionFactoryImplementor sessionFactory,
            boolean ignoreUnsupported) {
    MetadataContext context = new MetadataContext( sessionFactory, ignoreUnsupported );
    while ( persistentClasses.hasNext() ) {
      PersistentClass pc = persistentClasses.next();
      locateOrBuildEntityType( pc, context );
    }
    context.wrapUp();
    return new MetamodelImpl( context.getEntityTypeMap(), context.getEmbeddableTypeMap(), context.getMappedSuperclassTypeMap(), context.getEntityTypesByEntityName() );
  }
View Full Code Here

    AbstractIdentifiableType<?> superType = superMappedSuperclass == null
        ? null
        : locateOrBuildMappedsuperclassType( superMappedSuperclass, context );
    //no mappedSuperclass, check for a super entity
    if (superType == null) {
      final PersistentClass superPersistentClass = persistentClass.getSuperclass();
      superType = superPersistentClass == null
          ? null
          : locateOrBuildEntityType( superPersistentClass, context );
    }
    EntityTypeImpl entityType = new EntityTypeImpl(
View Full Code Here

    AbstractIdentifiableType<?> superType = superMappedSuperclass == null
        ? null
        : locateOrBuildMappedsuperclassType( superMappedSuperclass, context );
    //no mappedSuperclass, check for a super entity
    if (superType == null) {
      final PersistentClass superPersistentClass = mappedSuperclass.getSuperPersistentClass();
      superType = superPersistentClass == null
          ? null
          : locateOrBuildEntityType( superPersistentClass, context );
    }
    final Class javaType = mappedSuperclass.getMappedClass();
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.