Java 类org.hibernate.mapping.RootClass 实例源码

项目:lams    文件:HbmBinder.java   
private static void bindDiscriminatorProperty(Table table, RootClass entity, Element subnode,
        Mappings mappings) {
    SimpleValue discrim = new SimpleValue( mappings, table );
    entity.setDiscriminator( discrim );
    bindSimpleValue(
            subnode,
            discrim,
            false,
            RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME,
            mappings
        );
    if ( !discrim.isTypeSpecified() ) {
        discrim.setTypeName( "string" );
        // ( (Column) discrim.getColumnIterator().next() ).setType(type);
    }
    entity.setPolymorphic( true );
    final String explicitForceValue = subnode.attributeValue( "force" );
    boolean forceDiscriminatorInSelects = explicitForceValue == null
            ? mappings.forceDiscriminatorInSelectsByDefault()
            : "true".equals( explicitForceValue );
    entity.setForceDiscriminator( forceDiscriminatorInSelects );
    if ( "false".equals( subnode.attributeValue( "insert" ) ) ) {
        entity.setDiscriminatorInsertable( false );
    }
}
项目:lams    文件:AnnotationBinder.java   
private static void bindDiscriminatorColumnToRootPersistentClass(
        RootClass rootClass,
        Ejb3DiscriminatorColumn discriminatorColumn,
        Map<String, Join> secondaryTables,
        PropertyHolder propertyHolder,
        Mappings mappings) {
    if ( rootClass.getDiscriminator() == null ) {
        if ( discriminatorColumn == null ) {
            throw new AssertionFailure( "discriminator column should have been built" );
        }
        discriminatorColumn.setJoins( secondaryTables );
        discriminatorColumn.setPropertyHolder( propertyHolder );
        SimpleValue discriminatorColumnBinding = new SimpleValue( mappings, rootClass.getTable() );
        rootClass.setDiscriminator( discriminatorColumnBinding );
        discriminatorColumn.linkWithValue( discriminatorColumnBinding );
        discriminatorColumnBinding.setTypeName( discriminatorColumn.getDiscriminatorTypeName() );
        rootClass.setPolymorphic( true );
        if ( LOG.isTraceEnabled() ) {
            LOG.tracev( "Setting discriminator for entity {0}", rootClass.getEntityName() );
        }
    }
}
项目:cacheonix-core    文件:HbmBinder.java   
private static void bindDiscriminatorProperty(Table table, RootClass entity, Element subnode,
        Mappings mappings) {
    SimpleValue discrim = new SimpleValue( table );
    entity.setDiscriminator( discrim );
    bindSimpleValue(
            subnode,
            discrim,
            false,
            RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME,
            mappings
        );
    if ( !discrim.isTypeSpecified() ) {
        discrim.setTypeName( "string" );
        // ( (Column) discrim.getColumnIterator().next() ).setType(type);
    }
    entity.setPolymorphic( true );
    if ( "true".equals( subnode.attributeValue( "force" ) ) )
        entity.setForceDiscriminator( true );
    if ( "false".equals( subnode.attributeValue( "insert" ) ) )
        entity.setDiscriminatorInsertable( false );
}
项目:cacheonix-core    文件:ValueVisitorTest.java   
public void testProperCallbacks() {

        ValueVisitor vv = new ValueVisitorValidator();

        new Any(new Table()).accept(vv);
        new Array(new RootClass()).accept(vv);
        new Bag(new RootClass()).accept(vv);
        new Component(new RootClass()).accept(vv);
        new DependantValue(null,null).accept(vv);
        new IdentifierBag(null).accept(vv);
        new List(null).accept(vv);
        new ManyToOne(null).accept(vv);
        new Map(null).accept(vv);
        new OneToMany(null).accept(vv);
        new OneToOne(null, new RootClass() ).accept(vv);
        new PrimitiveArray(null).accept(vv);
        new Set(null).accept(vv);
        new SimpleValue().accept(vv);


    }
项目:hibernate-semantic-query    文件:EntityHierarchyImpl.java   
private static Table resolveIdentifierTable(
            PersisterCreationContext creationContext,
            RootClass rootEntityBinding) {
//      final JdbcEnvironment jdbcEnvironment = creationContext.getSessionFactory()
//              .getJdbcServices()
//              .getJdbcEnvironment();
        final org.hibernate.mapping.Table mappingTable = rootEntityBinding.getIdentityTable();
        if ( mappingTable.getSubselect() != null ) {
            return creationContext.getDatabaseModel().findDerivedTable( mappingTable.getSubselect() );
        }
        else {
//          final String name = jdbcEnvironment.getQualifiedObjectNameFormatter().format(
//                  mappingTable.getQualifiedTableName(),
//                  jdbcEnvironment.getDialect()
//          );
            final String name = mappingTable.getQualifiedTableName().render();
            return creationContext.getDatabaseModel().findPhysicalTable( name );

        }
    }
项目:lams    文件:HbmBinder.java   
private static void bindCompositeId(Element idNode, RootClass entity, Mappings mappings,
        java.util.Map inheritedMetas) throws MappingException {
    String propertyName = idNode.attributeValue( "name" );
    Component id = new Component( mappings, entity );
    entity.setIdentifier( id );
    bindCompositeId( idNode, id, entity, propertyName, mappings, inheritedMetas );
    if ( propertyName == null ) {
        entity.setEmbeddedIdentifier( id.isEmbedded() );
        if ( id.isEmbedded() ) {
            // todo : what is the implication of this?
            id.setDynamic( !entity.hasPojoRepresentation() );
            /*
             * Property prop = new Property(); prop.setName("id");
             * prop.setPropertyAccessorName("embedded"); prop.setValue(id);
             * entity.setIdentifierProperty(prop);
             */
        }
    }
    else {
        Property prop = new Property();
        prop.setValue( id );
        bindProperty( idNode, prop, mappings, inheritedMetas );
        entity.setIdentifierProperty( prop );
        entity.setDeclaredIdentifierProperty( prop );
    }

    makeIdentifier( idNode, id, mappings );

}
项目:lams    文件:HbmBinder.java   
private static void bindVersioningProperty(Table table, Element subnode, Mappings mappings,
        String name, RootClass entity, java.util.Map inheritedMetas) {

    String propertyName = subnode.attributeValue( "name" );
    SimpleValue val = new SimpleValue( mappings, table );
    bindSimpleValue( subnode, val, false, propertyName, mappings );
    if ( !val.isTypeSpecified() ) {
        // this is either a <version/> tag with no type attribute,
        // or a <timestamp/> tag
        if ( "version".equals( name ) ) {
            val.setTypeName( "integer" );
        }
        else {
            if ( "db".equals( subnode.attributeValue( "source" ) ) ) {
                val.setTypeName( "dbtimestamp" );
            }
            else {
                val.setTypeName( "timestamp" );
            }
        }
    }
    Property prop = new Property();
    prop.setValue( val );
    bindProperty( subnode, prop, mappings, inheritedMetas );
    // for version properties marked as being generated, make sure they are "always"
    // generated; aka, "insert" is invalid; this is dis-allowed by the DTD,
    // but just to make sure...
    if ( prop.getValueGenerationStrategy() != null ) {
        if ( prop.getValueGenerationStrategy().getGenerationTiming() == GenerationTiming.INSERT ) {
            throw new MappingException( "'generated' attribute cannot be 'insert' for versioning property" );
        }
    }
    makeVersion( subnode, val );
    entity.setVersion( prop );
    entity.addProperty( prop );
}
项目:lams    文件:Configuration.java   
RootClass getRootClassMapping(String clazz) throws MappingException {
    try {
        return (RootClass) getClassMapping( clazz );
    }
    catch (ClassCastException cce) {
        throw new MappingException( "You may only specify a cache for root <class> mappings.  Attempted on " + clazz );
    }
}
项目:lams    文件:Configuration.java   
private void applyCacheConcurrencyStrategy(CacheHolder holder) {
    RootClass rootClass = getRootClassMapping( holder.role );
    if ( rootClass == null ) {
        throw new MappingException( "Cannot cache an unknown entity: " + holder.role );
    }
    rootClass.setCacheConcurrencyStrategy( holder.usage );
    rootClass.setCacheRegionName( holder.region );
    rootClass.setLazyPropertiesCacheable( holder.cacheLazy );
}
项目:cacheonix-core    文件:HbmBinder.java   
private static void bindCompositeId(Element idNode, RootClass entity, Mappings mappings,
        java.util.Map inheritedMetas) throws MappingException {
    String propertyName = idNode.attributeValue( "name" );
    Component id = new Component( entity );
    entity.setIdentifier( id );
    bindCompositeId( idNode, id, entity, propertyName, mappings, inheritedMetas );
    if ( propertyName == null ) {
        entity.setEmbeddedIdentifier( id.isEmbedded() );
        if ( id.isEmbedded() ) {
            // todo : what is the implication of this?
            id.setDynamic( !entity.hasPojoRepresentation() );
            /*
             * Property prop = new Property(); prop.setName("id");
             * prop.setPropertyAccessorName("embedded"); prop.setValue(id);
             * entity.setIdentifierProperty(prop);
             */
        }
    }
    else {
        Property prop = new Property();
        prop.setValue( id );
        bindProperty( idNode, prop, mappings, inheritedMetas );
        entity.setIdentifierProperty( prop );
    }

    makeIdentifier( idNode, id, mappings );

}
项目:cacheonix-core    文件:HbmBinder.java   
private static void bindVersioningProperty(Table table, Element subnode, Mappings mappings,
        String name, RootClass entity, java.util.Map inheritedMetas) {

    String propertyName = subnode.attributeValue( "name" );
    SimpleValue val = new SimpleValue( table );
    bindSimpleValue( subnode, val, false, propertyName, mappings );
    if ( !val.isTypeSpecified() ) {
        // this is either a <version/> tag with no type attribute,
        // or a <timestamp/> tag
        if ( "version".equals( name ) ) {
            val.setTypeName( "integer" );
        }
        else {
            if ( "db".equals( subnode.attributeValue( "source" ) ) ) {
                val.setTypeName( "dbtimestamp" );
            }
            else {
                val.setTypeName( "timestamp" );
            }
        }
    }
    Property prop = new Property();
    prop.setValue( val );
    bindProperty( subnode, prop, mappings, inheritedMetas );
    // for version properties marked as being generated, make sure they are "always"
    // generated; aka, "insert" is invalid; this is dis-allowed by the DTD,
    // but just to make sure...
    if ( prop.getGeneration() == PropertyGeneration.INSERT ) {
        throw new MappingException( "'generated' attribute cannot be 'insert' for versioning property" );
    }
    makeVersion( subnode, val );
    entity.setVersion( prop );
    entity.addProperty( prop );
}
项目:cacheonix-core    文件:Configuration.java   
RootClass getRootClassMapping(String clazz) throws MappingException {
    try {
        return (RootClass) getClassMapping( clazz );
    }
    catch (ClassCastException cce) {
        throw new MappingException( "You may only specify a cache for root <class> mappings" );
    }
}
项目:cacheonix-core    文件:Configuration.java   
void setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy, String region, boolean includeLazy)
        throws MappingException {
    RootClass rootClass = getRootClassMapping( clazz );
    if ( rootClass == null ) {
        throw new MappingException( "Cannot cache an unknown entity: " + clazz );
    }
    rootClass.setCacheConcurrencyStrategy( concurrencyStrategy );
    rootClass.setCacheRegionName( region );
    rootClass.setLazyPropertiesCacheable( includeLazy );
}
项目:cacheonix-core    文件:PersistentClassVisitorTest.java   
public void testProperCallbacks() {

        PersistentClassVisitorValidator vv = new PersistentClassVisitorValidator();

        new RootClass().accept(vv);
        new Subclass(new RootClass()).accept(vv);
        new JoinedSubclass(new RootClass()).accept(vv);
        new SingleTableSubclass(new RootClass()).accept(vv);
        new UnionSubclass(new RootClass()).accept(vv);

    }
项目:hibernate-semantic-query    文件:EntityHierarchyImpl.java   
public EntityHierarchyImpl(
        PersisterCreationContext creationContext,
        RootClass rootEntityBinding,
        EntityPersister rootEntityPersister) {
    this.rootEntityPersister = rootEntityPersister;

    final Table identifierTable = resolveIdentifierTable( creationContext, rootEntityBinding );
    this.identifierDescriptor = interpretIdentifierDescriptor(
            this,
            rootEntityPersister,
            creationContext,
            rootEntityBinding,
            identifierTable
    );
}
项目:hibernate-semantic-query    文件:PersisterFactoryImpl.java   
@Override
public void finishUp(PersisterCreationContext creationContext) {
    for ( EntityHierarchyNode root : roots ) {
        // todo : resolve any MappedSuperclasses for supers of the root entity
        EntityHierarchy entityHierarchy = new EntityHierarchyImpl(
                creationContext,
                (RootClass) root.mappingType,
                (EntityPersister) root.ormJpaType
        );

        finishSupers( root.superEntityNode, entityHierarchy, creationContext );

        root.finishUp( entityHierarchy, creationContext );

        entityHierarchy.finishInitialization( creationContext, (RootClass) root.mappingType );
    }

    // todo :
    for ( final Collection model : creationContext.getMetadata().getCollectionBindings() ) {
        final CollectionPersister collectionPersister = creationContext.getTypeConfiguration().findCollectionPersister( model.getRole() );
        if ( collectionPersister == null ) {
            throw new HibernateException( "Collection role not properly materialized to CollectionPersister : " + model.getRole() );
        }
        collectionPersister.finishInitialization( model, creationContext );
    }

    for ( EmbeddableMapper mapper : creationContext.getTypeConfiguration().getEmbeddablePersisters() ) {
        mapper.afterInitialization(
                embeddableComponentMap.get( mapper ),
                creationContext
        );
    }


    serviceRegistry = null;
    roots.clear();
    nameToHierarchyNodeMap.clear();
    embeddableComponentMap.clear();
}
项目:ignite    文件:HibernateL2CacheStrategySelfTest.java   
/**
 * @param accessType Cache access typr.
 * @param igniteInstanceName Name of the grid providing caches.
 * @return Session factory.
 */
private SessionFactory startHibernate(AccessType accessType, String igniteInstanceName) {
    StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();

    builder.applySetting("hibernate.connection.url", CONNECTION_URL);

    for (Map.Entry<String, String> e : HibernateL2CacheSelfTest.hibernateProperties(igniteInstanceName, accessType.name()).entrySet())
        builder.applySetting(e.getKey(), e.getValue());

    builder.applySetting(USE_STRUCTURED_CACHE, "true");
    builder.applySetting(REGION_CACHE_PROPERTY + ENTITY1_NAME, "cache1");
    builder.applySetting(REGION_CACHE_PROPERTY + ENTITY2_NAME, "cache2");
    builder.applySetting(REGION_CACHE_PROPERTY + TIMESTAMP_CACHE, TIMESTAMP_CACHE);
    builder.applySetting(REGION_CACHE_PROPERTY + QUERY_CACHE, QUERY_CACHE);

    MetadataSources metadataSources = new MetadataSources(builder.build());

    metadataSources.addAnnotatedClass(Entity1.class);
    metadataSources.addAnnotatedClass(Entity2.class);
    metadataSources.addAnnotatedClass(Entity3.class);
    metadataSources.addAnnotatedClass(Entity4.class);

    Metadata metadata = metadataSources.buildMetadata();

    for (PersistentClass entityBinding : metadata.getEntityBindings()) {
        if (!entityBinding.isInherited())
            ((RootClass)entityBinding).setCacheConcurrencyStrategy(accessType.getExternalName());
    }

    return metadata.buildSessionFactory();
}
项目:ignite    文件:HibernateL2CacheSelfTest.java   
/**
 * Starts Hibernate.
 *
 * @param accessType Cache access type.
 * @param igniteInstanceName Ignite instance name.
 * @return Session factory.
 */
private SessionFactory startHibernate(org.hibernate.cache.spi.access.AccessType accessType, String igniteInstanceName) {
    StandardServiceRegistryBuilder builder = registryBuilder();

    for (Map.Entry<String, String> e : hibernateProperties(igniteInstanceName, accessType.name()).entrySet())
        builder.applySetting(e.getKey(), e.getValue());

    // Use the same cache for Entity and Entity2.
    builder.applySetting(REGION_CACHE_PROPERTY + ENTITY2_NAME, ENTITY_NAME);

    StandardServiceRegistry srvcRegistry = builder.build();

    MetadataSources metadataSources = new MetadataSources(srvcRegistry);

    for (Class entityClass : getAnnotatedClasses())
        metadataSources.addAnnotatedClass(entityClass);

    Metadata metadata = metadataSources.buildMetadata();

    for (PersistentClass entityBinding : metadata.getEntityBindings()) {
        if (!entityBinding.isInherited())
            ((RootClass)entityBinding).setCacheConcurrencyStrategy(accessType.getExternalName());
    }

    for (org.hibernate.mapping.Collection collectionBinding : metadata.getCollectionBindings())
        collectionBinding.setCacheConcurrencyStrategy(accessType.getExternalName() );

    return metadata.buildSessionFactory();
}
项目:cagrid-core    文件:HibernateConfigTypesInformationResolver.java   
public Object getClassDiscriminatorValue(String classname) throws TypesInformationException {
    Object identifier = discriminators.get(classname);
    if (identifier == null) {
        PersistentClass clazz = configuration.getClassMapping(classname);
        if (clazz != null) {
            if (clazz instanceof Subclass) {
                Subclass sub = (Subclass) clazz;
                if (sub.isJoinedSubclass()) {
                    identifier = Integer.valueOf(sub.getSubclassId());
                } else {
                    identifier = getShortClassName(classname);
                }
            } else if (clazz instanceof RootClass) {
                RootClass root = (RootClass) clazz;
                if (root.getDiscriminator() == null) {
                    identifier = Integer.valueOf(root.getSubclassId());
                } else {
                    identifier = getShortClassName(classname);
                }
            }
        } else {
            throw new TypesInformationException("Class " + classname + " not found in hibernate configuration");
        }
        discriminators.put(classname, identifier);
    }
    return identifier;
}
项目:cagrid-core    文件:HibernateConfigTypesInformationResolver.java   
public Object getClassDiscriminatorValue(String classname) throws TypesInformationException {
    LOG.debug("Getting class discriminator value for " + classname);
    Object identifier = discriminators.get(classname);
    if (identifier == null) {
        PersistentClass clazz = configuration.getClassMapping(classname);
        if (clazz != null) {
            if (clazz instanceof Subclass) {
                Subclass sub = (Subclass) clazz;
                if (sub.isJoinedSubclass()) {
                    LOG.debug("\t" + classname + " is a joined subclass");
                    identifier = Integer.valueOf(sub.getSubclassId());
                } else {
                    LOG.debug("\t" + classname + " is a named subclass");
                    identifier = getShortClassName(classname);
                }
            } else if (clazz instanceof RootClass) {
                LOG.debug("\t" + classname + " is a root class");
                RootClass root = (RootClass) clazz;
                if (root.getDiscriminator() == null) {
                    identifier = Integer.valueOf(root.getSubclassId());
                } else {
                    identifier = getShortClassName(classname);
                }
            }
        } else {
            throw new TypesInformationException("Class " + classname + " not found in hibernate configuration");
        }
        discriminators.put(classname, identifier);
    }
    return identifier;
}
项目:cagrid-core    文件:HibernateConfigTypesInformationResolver.java   
public Object getClassDiscriminatorValue(String classname) throws TypesInformationException {
    Object identifier = discriminators.get(classname);
    if (identifier == null) {
        PersistentClass clazz = configuration.getClassMapping(classname);
        if (clazz != null) {
            if (clazz instanceof Subclass) {
                Subclass sub = (Subclass) clazz;
                if (sub.isJoinedSubclass()) {
                    identifier = Integer.valueOf(sub.getSubclassId());
                } else {
                    identifier = getShortClassName(classname);
                }
            } else if (clazz instanceof RootClass) {
                RootClass root = (RootClass) clazz;
                if (root.getDiscriminator() == null) {
                    identifier = Integer.valueOf(root.getSubclassId());
                } else {
                    identifier = getShortClassName(classname);
                }
            }
        } else {
            throw new TypesInformationException("Class " + classname + " not found in hibernate configuration");
        }
        discriminators.put(classname, identifier);
    }
    return identifier;
}
项目:lams    文件:CreateKeySecondPass.java   
public CreateKeySecondPass(RootClass rootClass) {
    this.rootClass = rootClass;
}
项目:lams    文件:HbmBinder.java   
private static void bindSimpleId(Element idNode, RootClass entity, Mappings mappings,
        java.util.Map inheritedMetas) throws MappingException {
    String propertyName = idNode.attributeValue( "name" );

    SimpleValue id = new SimpleValue( mappings, entity.getTable() );
    entity.setIdentifier( id );

    // if ( propertyName == null || entity.getPojoRepresentation() == null ) {
    // bindSimpleValue( idNode, id, false, RootClass.DEFAULT_IDENTIFIER_COLUMN_NAME, mappings );
    // if ( !id.isTypeSpecified() ) {
    // throw new MappingException( "must specify an identifier type: " + entity.getEntityName()
    // );
    // }
    // }
    // else {
    // bindSimpleValue( idNode, id, false, propertyName, mappings );
    // PojoRepresentation pojo = entity.getPojoRepresentation();
    // id.setTypeUsingReflection( pojo.getClassName(), propertyName );
    //
    // Property prop = new Property();
    // prop.setValue( id );
    // bindProperty( idNode, prop, mappings, inheritedMetas );
    // entity.setIdentifierProperty( prop );
    // }

    if ( propertyName == null ) {
        bindSimpleValue( idNode, id, false, RootClass.DEFAULT_IDENTIFIER_COLUMN_NAME, mappings );
    }
    else {
        bindSimpleValue( idNode, id, false, propertyName, mappings );
    }

    if ( propertyName == null || !entity.hasPojoRepresentation() ) {
        if ( !id.isTypeSpecified() ) {
            throw new MappingException( "must specify an identifier type: "
                + entity.getEntityName() );
        }
    }
    else {
        id.setTypeUsingReflection( entity.getClassName(), propertyName );
    }

    if ( propertyName != null ) {
        Property prop = new Property();
        prop.setValue( id );
        bindProperty( idNode, prop, mappings, inheritedMetas );
        entity.setIdentifierProperty( prop );
        entity.setDeclaredIdentifierProperty( prop );
    }

    // TODO:
    /*
     * if ( id.getHibernateType().getReturnedClass().isArray() ) throw new MappingException(
     * "illegal use of an array as an identifier (arrays don't reimplement equals)" );
     */
    makeIdentifier( idNode, id, mappings );
}
项目:lams    文件:PropertyBinder.java   
private Property bind(Property prop) {
    if (isId) {
        final RootClass rootClass = ( RootClass ) holder.getPersistentClass();
        //if an xToMany, it as to be wrapped today.
        //FIXME this pose a problem as the PK is the class instead of the associated class which is not really compliant with the spec
        if ( isXToMany || entityBinder.wrapIdsInEmbeddedComponents() ) {
            Component identifier = (Component) rootClass.getIdentifier();
            if (identifier == null) {
                identifier = AnnotationBinder.createComponent( holder, new PropertyPreloadedData(null, null, null), true, false, mappings );
                rootClass.setIdentifier( identifier );
                identifier.setNullValue( "undefined" );
                rootClass.setEmbeddedIdentifier( true );
                rootClass.setIdentifierMapper( identifier );
            }
            //FIXME is it good enough?
            identifier.addProperty( prop );
        }
        else {
            rootClass.setIdentifier( ( KeyValue ) getValue() );
            if (embedded) {
                rootClass.setEmbeddedIdentifier( true );
            }
            else {
                rootClass.setIdentifierProperty( prop );
                final org.hibernate.mapping.MappedSuperclass superclass = BinderHelper.getMappedSuperclassOrNull(
                        declaringClass,
                        inheritanceStatePerClass,
                        mappings
                );
                if (superclass != null) {
                    superclass.setDeclaredIdentifierProperty(prop);
                }
                else {
                    //we know the property is on the actual entity
                    rootClass.setDeclaredIdentifierProperty( prop );
                }
            }
        }
    }
    else {
        holder.addProperty( prop, columns, declaringClass );
    }
    return prop;
}
项目:lams    文件:EntityBinder.java   
public boolean isRootEntity() {
    // This is the best option I can think of here since PersistentClass is most likely not yet fully populated
    return persistentClass instanceof RootClass;
}
项目:cacheonix-core    文件:HbmBinder.java   
private static void bindSimpleId(Element idNode, RootClass entity, Mappings mappings,
        java.util.Map inheritedMetas) throws MappingException {
    String propertyName = idNode.attributeValue( "name" );

    SimpleValue id = new SimpleValue( entity.getTable() );
    entity.setIdentifier( id );

    // if ( propertyName == null || entity.getPojoRepresentation() == null ) {
    // bindSimpleValue( idNode, id, false, RootClass.DEFAULT_IDENTIFIER_COLUMN_NAME, mappings );
    // if ( !id.isTypeSpecified() ) {
    // throw new MappingException( "must specify an identifier type: " + entity.getEntityName()
    // );
    // }
    // }
    // else {
    // bindSimpleValue( idNode, id, false, propertyName, mappings );
    // PojoRepresentation pojo = entity.getPojoRepresentation();
    // id.setTypeUsingReflection( pojo.getClassName(), propertyName );
    //
    // Property prop = new Property();
    // prop.setValue( id );
    // bindProperty( idNode, prop, mappings, inheritedMetas );
    // entity.setIdentifierProperty( prop );
    // }

    if ( propertyName == null ) {
        bindSimpleValue( idNode, id, false, RootClass.DEFAULT_IDENTIFIER_COLUMN_NAME, mappings );
    }
    else {
        bindSimpleValue( idNode, id, false, propertyName, mappings );
    }

    if ( propertyName == null || !entity.hasPojoRepresentation() ) {
        if ( !id.isTypeSpecified() ) {
            throw new MappingException( "must specify an identifier type: "
                + entity.getEntityName() );
        }
    }
    else {
        id.setTypeUsingReflection( entity.getClassName(), propertyName );
    }

    if ( propertyName != null ) {
        Property prop = new Property();
        prop.setValue( id );
        bindProperty( idNode, prop, mappings, inheritedMetas );
        entity.setIdentifierProperty( prop );
    }

    // TODO:
    /*
     * if ( id.getHibernateType().getReturnedClass().isArray() ) throw new MappingException(
     * "illegal use of an array as an identifier (arrays don't reimplement equals)" );
     */
    makeIdentifier( idNode, id, mappings );
}
项目:cacheonix-core    文件:PersistentClassVisitorTest.java   
public Object accept(RootClass class1) {
    return validate(RootClass.class, class1);
}
项目:cacheonix-core    文件:FooBarTest.java   
public void configure(Configuration cfg) {
    super.configure( cfg );
    if ( Dialect.getDialect() instanceof OracleDialect ) {
        ( (RootClass) cfg.getClassMapping("org.hibernate.test.legacy.Foo") ).setForceDiscriminator(false);
    }
}
项目:hibernate-semantic-query    文件:EntityHierarchyImpl.java   
private static IdentifierDescriptor interpretIdentifierDescriptor(
            EntityHierarchyImpl hierarchy,
            EntityPersister rootEntityPersister,
            PersisterCreationContext creationContext,
            RootClass rootEntityBinding,
            Table identifierTable) {
        final KeyValue identifierValueMapping = rootEntityBinding.getIdentifier();

        final List<Column> idColumns = resolveColumns( identifierTable, identifierValueMapping, creationContext );

        if ( identifierValueMapping.getType() instanceof org.hibernate.type.BasicType ) {
            return new IdentifierDescriptorSimpleImpl(
                    hierarchy.getRootEntityPersister(),
                    rootEntityBinding.getIdentifierProperty().getName(),
                    OrmTypeHelper.convertBasic(
                            (org.hibernate.type.BasicType) identifierValueMapping.getType(),
                            creationContext.getTypeConfiguration()
                    ),
                    idColumns
            );
        }
        else {
            final CompositeType cidType = (CompositeType) identifierValueMapping.getType();
            // todo : need to pass along that any built sub attributes are part of the id
            if ( rootEntityBinding.hasIdentifierProperty() ) {
                return new IdentifierDescriptorAggregatedEmbeddedImpl(
                        (SingularAttributeEmbedded) PersisterHelper.INSTANCE.buildSingularAttribute(
                                creationContext,
                                // the declaring type...
                                ///     for now we use the root entity
                                hierarchy.getRootEntityPersister(),
                                // value?
                                null,
                                rootEntityBinding.getIdentifierProperty().getName(),
                                OrmTypeHelper.convertComposite(
                                        creationContext,
                                        rootEntityBinding.getIdentifierProperty().getName(),
                                        (Component) identifierValueMapping,
                                        hierarchy.getRootEntityPersister(),
                                        creationContext.getTypeConfiguration()
                                ),
                                idColumns
                        )
                );
            }
            else {
                // todo : pass info about ther IdClass
                return new IdentifierDescriptorNonAggregatedEmbeddedImpl(
                        rootEntityPersister,
                        OrmTypeHelper.convertComposite(
                                creationContext,
                                "<id>",
                                (Component) identifierValueMapping,
                                hierarchy.getRootEntityPersister(),
                                creationContext.getTypeConfiguration()
                        ),
                        OrmTypeHelper.convertComposite(
                                creationContext,
                                "<IdClass>",
                                rootEntityBinding.getIdentifierMapper(),
                                hierarchy.getRootEntityPersister(),
                                creationContext.getTypeConfiguration()
                        )
                );

//                      PersisterHelper.INSTANCE.buildEmbeddablePersister(
//                              creationContext,
//                              hierarchy.getRootEntityPersister(),
//                              rootEntityBinding.getEntityName() + ".id",
//                              cidType,
//                              idColumns
//                      )
            }
        }
    }
项目:hibernate-semantic-query    文件:EntityHierarchyImpl.java   
@Override
public void finishInitialization(PersisterCreationContext creationContext, RootClass mappingType) {
    // todo : identifierDescriptor init, etc
}
项目:lams    文件:HbmBinder.java   
/**
 * Responsible for performing the bind operation related to an &lt;class/&gt; mapping element.
 *
 * @param node The DOM Element for the &lt;class/&gt; element.
 * @param rootClass The mapping instance to which to bind the information.
 * @param mappings The current bind state.
 * @param inheritedMetas Any inherited meta-tag information.
 * @throws MappingException
 */
public static void bindRootClass(Element node, RootClass rootClass, Mappings mappings,
        java.util.Map inheritedMetas) throws MappingException {
    bindClass( node, rootClass, mappings, inheritedMetas );
    inheritedMetas = getMetas( node, inheritedMetas, true ); // get meta's from <class>
    bindRootPersistentClassCommonValues( node, inheritedMetas, mappings, rootClass );
}
项目:cacheonix-core    文件:HbmBinder.java   
/**
 * Responsible for perfoming the bind operation related to an &lt;class/&gt; mapping element.
 *
 * @param node The DOM Element for the &lt;class/&gt; element.
 * @param rootClass The mapping instance to which to bind the information.
 * @param mappings The current bind state.
 * @param inheritedMetas Any inherited meta-tag information.
 * @throws MappingException
 */
public static void bindRootClass(Element node, RootClass rootClass, Mappings mappings,
        java.util.Map inheritedMetas) throws MappingException {
    bindClass( node, rootClass, mappings, inheritedMetas );
    inheritedMetas = getMetas( node, inheritedMetas, true ); // get meta's from <class>
    bindRootPersistentClassCommonValues( node, inheritedMetas, mappings, rootClass );
}
项目:hibernate-semantic-query    文件:EntityHierarchy.java   
void finishInitialization(PersisterCreationContext creationContext, RootClass mappingType);