Java 类org.hibernate.metamodel.binding.EntityBinding 实例源码

项目:lams    文件:Binder.java   
private EntityBinding createEntityBinding(EntitySource entitySource, EntityBinding superEntityBinding) {
    if ( processedEntityNames.contains( entitySource.getEntityName() ) ) {
        return metadata.getEntityBinding( entitySource.getEntityName() );
    }

    currentBindingContext = entitySource.getLocalBindingContext();
    try {
        final EntityBinding entityBinding = doCreateEntityBinding( entitySource, superEntityBinding );

        metadata.addEntity( entityBinding );
        processedEntityNames.add( entityBinding.getEntity().getName() );

        processFetchProfiles( entitySource, entityBinding );

        return entityBinding;
    }
    finally {
        currentBindingContext = null;
    }
}
项目:lams    文件:Binder.java   
private EntityBinding createBasicEntityBinding(EntitySource entitySource, EntityBinding superEntityBinding) {
    if ( superEntityBinding == null ) {
        return makeRootEntityBinding( (RootEntitySource) entitySource );
    }
    else {
        switch ( currentInheritanceType ) {
            case SINGLE_TABLE:
                return makeDiscriminatedSubclassBinding( (SubclassEntitySource) entitySource, superEntityBinding );
            case JOINED:
                return makeJoinedSubclassBinding( (SubclassEntitySource) entitySource, superEntityBinding );
            case TABLE_PER_CLASS:
                return makeUnionedSubclassBinding( (SubclassEntitySource) entitySource, superEntityBinding );
            default:
                // extreme internal error!
                throw new AssertionFailure( "Internal condition failure" );
        }
    }
}
项目:lams    文件:Binder.java   
private EntityBinding makeRootEntityBinding(RootEntitySource entitySource) {
    currentHierarchyEntityMode = entitySource.getEntityMode();

    final EntityBinding entityBinding = buildBasicEntityBinding( entitySource, null );

    bindPrimaryTable( entitySource, entityBinding );

    bindIdentifier( entitySource, entityBinding );
    bindVersion( entityBinding, entitySource );
    bindDiscriminator( entitySource, entityBinding );

    entityBinding.getHierarchyDetails().setCaching( entitySource.getCaching() );
    entityBinding.getHierarchyDetails().setExplicitPolymorphism( entitySource.isExplicitPolymorphism() );
    entityBinding.getHierarchyDetails().setOptimisticLockStyle( entitySource.getOptimisticLockStyle() );

    entityBinding.setMutable( entitySource.isMutable() );
    entityBinding.setWhereFilter( entitySource.getWhere() );
    entityBinding.setRowId( entitySource.getRowId() );

    return entityBinding;
}
项目:lams    文件:Binder.java   
private void bindIdentifier(RootEntitySource entitySource, EntityBinding entityBinding) {
    if ( entitySource.getIdentifierSource() == null ) {
        throw new AssertionFailure( "Expecting identifier information on root entity descriptor" );
    }
    switch ( entitySource.getIdentifierSource().getNature() ) {
        case SIMPLE: {
            bindSimpleIdentifier( (SimpleIdentifierSource) entitySource.getIdentifierSource(), entityBinding );
            break;
        }
        case AGGREGATED_COMPOSITE: {
            // composite id with an actual component class
            break;
        }
        case COMPOSITE: {
            // what we used to term an "embedded composite identifier", which is not tobe confused with the JPA
            // term embedded. Specifically a composite id where there is no component class, though there may
            // be a @IdClass :/
            break;
        }
    }
}
项目:lams    文件:Binder.java   
private void bindDiscriminator(RootEntitySource entitySource, EntityBinding entityBinding) {
    final DiscriminatorSource discriminatorSource = entitySource.getDiscriminatorSource();
    if ( discriminatorSource == null ) {
        return;
    }

    EntityDiscriminator discriminator = new EntityDiscriminator();
    SimpleValue relationalValue = makeSimpleValue(
            entityBinding,
            discriminatorSource.getDiscriminatorRelationalValueSource()
    );
    discriminator.setBoundValue( relationalValue );

    discriminator.getExplicitHibernateTypeDescriptor().setExplicitTypeName(
            discriminatorSource.getExplicitHibernateTypeName() != null
                    ? discriminatorSource.getExplicitHibernateTypeName()
                    : "string"
    );

    discriminator.setInserted( discriminatorSource.isInserted() );
    discriminator.setForced( discriminatorSource.isForced() );

    entityBinding.getHierarchyDetails().setEntityDiscriminator( discriminator );
    entityBinding.setDiscriminatorMatchValue( entitySource.getDiscriminatorMatchValue() );
}
项目:lams    文件:Binder.java   
private Table createTable(EntityBinding entityBinding, TableSource tableSource) {
    String tableName = tableSource.getExplicitTableName();
    if ( StringHelper.isEmpty( tableName ) ) {
        tableName = currentBindingContext.getNamingStrategy()
                .classToTableName( entityBinding.getEntity().getClassName() );
    }
    else {
        tableName = currentBindingContext.getNamingStrategy().tableName( tableName );
    }
    tableName = quoteIdentifier( tableName );

    final Schema.Name databaseSchemaName = Helper.determineDatabaseSchemaName(
            tableSource.getExplicitSchemaName(),
            tableSource.getExplicitCatalogName(),
            currentBindingContext
    );
    return currentBindingContext.getMetadataImplementor()
            .getDatabase()
            .locateSchema( databaseSchemaName )
            .locateOrCreateTable( Identifier.toIdentifier( tableName ) );
}
项目:lams    文件:Binder.java   
private void bindTableUniqueConstraints(EntitySource entitySource, EntityBinding entityBinding) {
    for ( ConstraintSource constraintSource : entitySource.getConstraints() ) {
        if ( constraintSource instanceof UniqueConstraintSource ) {
            TableSpecification table = entityBinding.locateTable( constraintSource.getTableName() );
            if ( table == null ) {
                // throw exception !?
            }
            String constraintName = constraintSource.name();
            if ( constraintName == null ) {
                // create a default name
            }

            UniqueKey uniqueKey = table.getOrCreateUniqueKey( constraintName );
            for ( String columnName : constraintSource.columnNames() ) {
                uniqueKey.addColumn( table.locateOrCreateColumn( quoteIdentifier( columnName ) ) );
            }
        }
    }
}
项目:lams    文件:HibernateTypeResolver.java   
void resolve() {
    for ( EntityBinding entityBinding : metadata.getEntityBindings() ) {
        if ( entityBinding.getHierarchyDetails().getEntityDiscriminator() != null ) {
            resolveDiscriminatorTypeInformation( entityBinding.getHierarchyDetails().getEntityDiscriminator() );
        }
        for ( AttributeBinding attributeBinding : entityBinding.attributeBindings() ) {
            if ( SingularAttributeBinding.class.isInstance( attributeBinding ) ) {
                resolveSingularAttributeTypeInformation(
                        SingularAttributeBinding.class.cast( attributeBinding  )
                );
            }
            else if ( AbstractPluralAttributeBinding.class.isInstance( attributeBinding ) ) {
                resolvePluralAttributeTypeInformation(
                        AbstractPluralAttributeBinding.class.cast( attributeBinding )
                );
            }
            else {
                throw new AssertionFailure( "Unknown type of AttributeBinding: " + attributeBinding.getClass().getName() );
            }
        }
    }
}
项目:lams    文件:MetadataImpl.java   
@Override
public EntityBinding getRootEntityBinding(String entityName) {
    EntityBinding binding = entityBindingMap.get( entityName );
    if ( binding == null ) {
        throw new IllegalStateException( "Unknown entity binding: " + entityName );
    }

    do {
        if ( binding.isRoot() ) {
            return binding;
        }
        binding = binding.getSuperEntityBinding();
    } while ( binding != null );

    throw new AssertionFailure( "Entity binding has no root: " + entityName );
}
项目:lams    文件:UnionSubclassEntityPersister.java   
public UnionSubclassEntityPersister(
        final EntityBinding entityBinding,
        final EntityRegionAccessStrategy cacheAccessStrategy,
        final NaturalIdRegionAccessStrategy naturalIdRegionAccessStrategy,
        final SessionFactoryImplementor factory,
        final Mapping mapping) throws HibernateException {
    super(entityBinding, cacheAccessStrategy, naturalIdRegionAccessStrategy, factory );
    // TODO: implement!!! initializing final fields to null to make compiler happy.
    subquery = null;
    tableName = null;
    subclassClosure = null;
    spaces = null;
    subclassSpaces = null;
    discriminatorValue = null;
    discriminatorSQLValue = null;
    constraintOrderedTableNames = null;
    constraintOrderedKeyColumnNames = null;
}
项目:lams    文件:DynamicMapEntityTuplizer.java   
@Override
protected ProxyFactory buildProxyFactory(EntityBinding mappingInfo, Getter idGetter, Setter idSetter) {

    ProxyFactory pf = new MapProxyFactory();
    try {
        //TODO: design new lifecycle for ProxyFactory
        pf.postInstantiate(
                getEntityName(),
                null,
                null,
                null,
                null,
                null
        );
    }
    catch ( HibernateException he ) {
        LOG.unableToCreateProxyFactory(getEntityName(), he);
        pf = null;
    }
    return pf;
}
项目:lams    文件:Binder.java   
/**
 * Process an entity hierarchy.
 *
 * @param entityHierarchy THe hierarchy to process.
 */
public void processEntityHierarchy(EntityHierarchy entityHierarchy) {
    currentInheritanceType = entityHierarchy.getHierarchyInheritanceType();
    EntityBinding rootEntityBinding = createEntityBinding( entityHierarchy.getRootEntitySource(), null );
    if ( currentInheritanceType != InheritanceType.NO_INHERITANCE ) {
        processHierarchySubEntities( entityHierarchy.getRootEntitySource(), rootEntityBinding );
    }
    currentHierarchyEntityMode = null;
}
项目:lams    文件:Binder.java   
private EntityBinding makeDiscriminatedSubclassBinding(SubclassEntitySource entitySource, EntityBinding superEntityBinding) {
    final EntityBinding entityBinding = buildBasicEntityBinding( entitySource, superEntityBinding );

    entityBinding.setPrimaryTable( superEntityBinding.getPrimaryTable() );
    entityBinding.setPrimaryTableName( superEntityBinding.getPrimaryTableName() );
    bindDiscriminatorValue( entitySource, entityBinding );

    return entityBinding;
}
项目:lams    文件:Binder.java   
private void bindSimpleIdentifier(SimpleIdentifierSource identifierSource, EntityBinding entityBinding) {
    final BasicAttributeBinding idAttributeBinding = doBasicSingularAttributeBindingCreation(
            identifierSource.getIdentifierAttributeSource(), entityBinding
    );

    entityBinding.getHierarchyDetails().getEntityIdentifier().setValueBinding( idAttributeBinding );
    IdGenerator generator = identifierSource.getIdentifierGeneratorDescriptor();
    if ( generator == null ) {
        Map<String, String> params = new HashMap<String, String>();
        params.put( IdentifierGenerator.ENTITY_NAME, entityBinding.getEntity().getName() );
        generator = new IdGenerator( "default_assign_identity_generator", "assigned", params );
    }
    entityBinding.getHierarchyDetails()
            .getEntityIdentifier()
            .setIdGenerator( generator );

    final org.hibernate.metamodel.relational.Value relationalValue = idAttributeBinding.getValue();

    if ( SimpleValue.class.isInstance( relationalValue ) ) {
        if ( !Column.class.isInstance( relationalValue ) ) {
            // this should never ever happen..
            throw new AssertionFailure( "Simple-id was not a column." );
        }
        entityBinding.getPrimaryTable().getPrimaryKey().addColumn( Column.class.cast( relationalValue ) );
    }
    else {
        for ( SimpleValue subValue : ( (Tuple) relationalValue ).values() ) {
            if ( Column.class.isInstance( subValue ) ) {
                entityBinding.getPrimaryTable().getPrimaryKey().addColumn( Column.class.cast( subValue ) );
            }
        }
    }
}
项目:lams    文件:Binder.java   
private void bindVersion(EntityBinding entityBinding, RootEntitySource entitySource) {
    final SingularAttributeSource versioningAttributeSource = entitySource.getVersioningAttributeSource();
    if ( versioningAttributeSource == null ) {
        return;
    }

    BasicAttributeBinding attributeBinding = doBasicSingularAttributeBindingCreation(
            versioningAttributeSource, entityBinding
    );
    entityBinding.getHierarchyDetails().setVersioningAttributeBinding( attributeBinding );
}
项目:lams    文件:Binder.java   
private void bindDiscriminatorValue(SubclassEntitySource entitySource, EntityBinding entityBinding) {
    final String discriminatorValue = entitySource.getDiscriminatorMatchValue();
    if ( discriminatorValue == null ) {
        return;
    }
    entityBinding.setDiscriminatorMatchValue( discriminatorValue );
}
项目:lams    文件:Binder.java   
private SimpleValue makeSimpleValue(
        EntityBinding entityBinding,
        RelationalValueSource valueSource) {
    final TableSpecification table = entityBinding.locateTable( valueSource.getContainingTableName() );

    if ( ColumnSource.class.isInstance( valueSource ) ) {
        return makeColumn( (ColumnSource) valueSource, table );
    }
    else {
        return makeDerivedValue( (DerivedValueSource) valueSource, table );
    }
}
项目:lams    文件:IdentifierGeneratorResolver.java   
@SuppressWarnings( {"unchecked"} )
void resolve() {
    for ( EntityBinding entityBinding : metadata.getEntityBindings() ) {
        if ( entityBinding.isRoot() ) {
            Properties properties = new Properties( );
            properties.putAll(
                    metadata.getServiceRegistry()
                            .getService( ConfigurationService.class )
                            .getSettings()
            );
            //TODO: where should these be added???
            if ( ! properties.contains( AvailableSettings.PREFER_POOLED_VALUES_LO ) ) {
                properties.put( AvailableSettings.PREFER_POOLED_VALUES_LO, "false" );
            }
            if ( ! properties.contains( PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER ) ) {
                properties.put(
                        PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER,
                        new ObjectNameNormalizerImpl( metadata )
                );
            }
            entityBinding.getHierarchyDetails().getEntityIdentifier().createIdentifierGenerator(
                    metadata.getIdentifierGeneratorFactory(),
                    properties
            );
        }
    }
}
项目:lams    文件:AssociationResolver.java   
void resolve() {
    for ( EntityBinding entityBinding : metadata.getEntityBindings() ) {
        for ( SingularAssociationAttributeBinding attributeBinding : entityBinding.getEntityReferencingAttributeBindings() ) {
            resolve( attributeBinding );
        }
    }
}
项目:lams    文件:AssociationResolver.java   
private void resolve(SingularAssociationAttributeBinding attributeBinding) {
    if ( attributeBinding.getReferencedEntityName() == null ) {
        throw new IllegalArgumentException(
                "attributeBinding has null entityName: " + attributeBinding.getAttribute().getName()
        );
    }
    EntityBinding entityBinding = metadata.getEntityBinding( attributeBinding.getReferencedEntityName() );
    if ( entityBinding == null ) {
        throw new org.hibernate.MappingException(
                String.format(
                        "Attribute [%s] refers to unknown entity: [%s]",
                        attributeBinding.getAttribute().getName(),
                        attributeBinding.getReferencedEntityName()
                )
        );
    }
    AttributeBinding referencedAttributeBinding =
            attributeBinding.isPropertyReference() ?
                    entityBinding.locateAttributeBinding( attributeBinding.getReferencedAttributeName() ) :
                    entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding();
    if ( referencedAttributeBinding == null ) {
        // TODO: does attribute name include path w/ entity name?
        throw new org.hibernate.MappingException(
                String.format(
                        "Attribute [%s] refers to unknown attribute: [%s]",
                        attributeBinding.getAttribute().getName(),
                        attributeBinding.getReferencedEntityName()
                )
        );
    }
    attributeBinding.resolveReference( referencedAttributeBinding );
    referencedAttributeBinding.addEntityReferencingAttributeBinding( attributeBinding );
}
项目:lams    文件:MetadataImpl.java   
public void addEntity(EntityBinding entityBinding) {
    final String entityName = entityBinding.getEntity().getName();
    if ( entityBindingMap.containsKey( entityName ) ) {
        throw new DuplicateMappingException( DuplicateMappingException.Type.ENTITY, entityName );
    }
    entityBindingMap.put( entityName, entityBinding );
}
项目:lams    文件:MetadataImpl.java   
@Override
public org.hibernate.type.Type getIdentifierType(String entityName) throws MappingException {
    EntityBinding entityBinding = getEntityBinding( entityName );
    if ( entityBinding == null ) {
        throw new MappingException( "Entity binding not known: " + entityName );
    }
    return entityBinding
            .getHierarchyDetails()
            .getEntityIdentifier()
            .getValueBinding()
            .getHibernateTypeDescriptor()
            .getResolvedTypeMapping();
}
项目:lams    文件:MetadataImpl.java   
@Override
public String getIdentifierPropertyName(String entityName) throws MappingException {
    EntityBinding entityBinding = getEntityBinding( entityName );
    if ( entityBinding == null ) {
        throw new MappingException( "Entity binding not known: " + entityName );
    }
    AttributeBinding idBinding = entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding();
    return idBinding == null ? null : idBinding.getAttribute().getName();
}
项目:lams    文件:MetadataImpl.java   
@Override
public org.hibernate.type.Type getReferencedPropertyType(String entityName, String propertyName) throws MappingException {
    EntityBinding entityBinding = getEntityBinding( entityName );
    if ( entityBinding == null ) {
        throw new MappingException( "Entity binding not known: " + entityName );
    }
    // TODO: should this call EntityBinding.getReferencedAttributeBindingString), which does not exist yet?
    AttributeBinding attributeBinding = entityBinding.locateAttributeBinding( propertyName );
    if ( attributeBinding == null ) {
        throw new MappingException( "unknown property: " + entityName + '.' + propertyName );
    }
    return attributeBinding.getHibernateTypeDescriptor().getResolvedTypeMapping();
}
项目:lams    文件:StandardPersisterClassResolver.java   
public Class<? extends EntityPersister> getEntityPersisterClass(EntityBinding metadata) {
    if ( metadata.isRoot() ) {
           Iterator<EntityBinding> subEntityBindingIterator = metadata.getDirectSubEntityBindings().iterator();
           if ( subEntityBindingIterator.hasNext() ) {
               //If the class has children, we need to find of which kind
               metadata = subEntityBindingIterator.next();
           }
           else {
            return singleTableEntityPersister();
           }
    }
    switch ( metadata.getHierarchyDetails().getInheritanceType() ) {
        case JOINED: {
            return joinedSubclassEntityPersister();
        }
        case SINGLE_TABLE: {
            return singleTableEntityPersister();
        }
        case TABLE_PER_CLASS: {
            return unionSubclassEntityPersister();
        }
        default: {
            throw new UnknownPersisterException(
                    "Could not determine persister implementation for entity [" + metadata.getEntity().getName() + "]"
            );
        }

    }
}
项目:lams    文件:PersisterFactoryImpl.java   
@Override
@SuppressWarnings( {"unchecked"})
public EntityPersister createEntityPersister(EntityBinding metadata,
                                             EntityRegionAccessStrategy cacheAccessStrategy,
                                             SessionFactoryImplementor factory,
                                             Mapping cfg) {
    Class<? extends EntityPersister> persisterClass = metadata.getCustomEntityPersisterClass();
    if ( persisterClass == null ) {
        persisterClass = serviceRegistry.getService( PersisterClassResolver.class ).getEntityPersisterClass( metadata );
    }
    return create( persisterClass, ENTITY_PERSISTER_CONSTRUCTOR_ARGS_NEW, metadata, cacheAccessStrategy, null, factory, cfg );
}
项目:lams    文件:EntityTuplizerFactory.java   
/**
 * Construct an instance of the given tuplizer class.
 *
 * @param tuplizerClassName The name of the tuplizer class to instantiate
 * @param metamodel The metadata for the entity.
 * @param entityBinding The mapping info for the entity.
 *
 * @return The instantiated tuplizer
 *
 * @throws HibernateException If class name cannot be resolved to a class reference, or if the
 * {@link Constructor#newInstance} call fails.
 */
@SuppressWarnings({ "unchecked" })
public EntityTuplizer constructTuplizer(
        String tuplizerClassName,
        EntityMetamodel metamodel,
        EntityBinding entityBinding) {
    try {
        Class<? extends EntityTuplizer> tuplizerClass = ReflectHelper.classForName( tuplizerClassName );
        return constructTuplizer( tuplizerClass, metamodel, entityBinding );
    }
    catch ( ClassNotFoundException e ) {
        throw new HibernateException( "Could not locate specified tuplizer class [" + tuplizerClassName + "]" );
    }
}
项目:lams    文件:EntityTuplizerFactory.java   
/**
 * Construct an instance of the given tuplizer class.
 *
 * @param tuplizerClass The tuplizer class to instantiate
 * @param metamodel The metadata for the entity.
 * @param entityBinding The mapping info for the entity.
 *
 * @return The instantiated tuplizer
 *
 * @throws HibernateException if the {@link Constructor#newInstance} call fails.
 */
public EntityTuplizer constructTuplizer(
        Class<? extends EntityTuplizer> tuplizerClass,
        EntityMetamodel metamodel,
        EntityBinding entityBinding) {
    Constructor<? extends EntityTuplizer> constructor = getProperConstructor( tuplizerClass, ENTITY_TUP_CTOR_SIG_NEW );
    assert constructor != null : "Unable to locate proper constructor for tuplizer [" + tuplizerClass.getName() + "]";
    try {
        return constructor.newInstance( metamodel, entityBinding );
    }
    catch ( Throwable t ) {
        throw new HibernateException( "Unable to instantiate default tuplizer [" + tuplizerClass.getName() + "]", t );
    }
}
项目:lams    文件:PojoEntityTuplizer.java   
public PojoEntityTuplizer(EntityMetamodel entityMetamodel, EntityBinding mappedEntity) {
        super( entityMetamodel, mappedEntity );
        this.mappedClass = mappedEntity.getEntity().getClassReference();
        this.proxyInterface = mappedEntity.getProxyInterfaceType().getValue();
        this.lifecycleImplementor = Lifecycle.class.isAssignableFrom( mappedClass );
        this.isInstrumented = entityMetamodel.isInstrumented();

        for ( AttributeBinding property : mappedEntity.getAttributeBindingClosure() ) {
            if ( property.isLazy() ) {
                lazyPropertyNames.add( property.getAttribute().getName() );
            }
        }

        String[] getterNames = new String[propertySpan];
        String[] setterNames = new String[propertySpan];
        Class[] propTypes = new Class[propertySpan];
        for ( int i = 0; i < propertySpan; i++ ) {
            getterNames[i] = getters[ i ].getMethodName();
            setterNames[i] = setters[ i ].getMethodName();
            propTypes[i] = getters[ i ].getReturnType();
        }

        if ( hasCustomAccessors || ! Environment.useReflectionOptimizer() ) {
            optimizer = null;
        }
        else {
            // todo : YUCK!!!
            optimizer = Environment.getBytecodeProvider().getReflectionOptimizer(
                    mappedClass, getterNames, setterNames, propTypes
            );
//          optimizer = getFactory().getSettings().getBytecodeProvider().getReflectionOptimizer(
//                  mappedClass, getterNames, setterNames, propTypes
//          );
        }
    }
项目:lams    文件:PojoEntityTuplizer.java   
@Override
protected Instantiator buildInstantiator(EntityBinding entityBinding) {
    if ( optimizer == null ) {
        return new PojoInstantiator( entityBinding, null );
    }
    else {
        return new PojoInstantiator( entityBinding, optimizer.getInstantiationOptimizer() );
    }
}
项目:lams    文件:PojoInstantiator.java   
public PojoInstantiator(EntityBinding entityBinding, ReflectionOptimizer.InstantiationOptimizer optimizer) {
    this.mappedClass = entityBinding.getEntity().getClassReference();
    this.isAbstract = ReflectHelper.isAbstractClass( mappedClass );
    this.proxyInterface = entityBinding.getProxyInterfaceType().getValue();
    this.embeddedIdentifier = entityBinding.getHierarchyDetails().getEntityIdentifier().isEmbedded();
    this.optimizer = optimizer;

    try {
        constructor = ReflectHelper.getDefaultConstructor( mappedClass );
    }
    catch ( PropertyNotFoundException pnfe ) {
        LOG.noDefaultConstructor(mappedClass.getName());
        constructor = null;
    }
}
项目:lams    文件:DynamicMapInstantiator.java   
public DynamicMapInstantiator(EntityBinding mappingInfo) {
    this.entityName = mappingInfo.getEntity().getName();
    isInstanceEntityNames.add( entityName );
    for ( EntityBinding subEntityBinding : mappingInfo.getPostOrderSubEntityBindingClosure() ) {
        isInstanceEntityNames.add( subEntityBinding.getEntity().getName() );
    }
}
项目:lams    文件:PropertyFactory.java   
private static Constructor getConstructor(EntityBinding entityBinding) {
    if ( entityBinding == null || entityBinding.getEntity() == null ) {
        return null;
    }

    try {
        return ReflectHelper.getDefaultConstructor( entityBinding.getEntity().getClassReference() );
    }
    catch( Throwable t ) {
        return null;
    }
}
项目:lams    文件:CacheDataDescriptionImpl.java   
private static Comparator getVersionComparator(EntityBinding model ) {
    if ( model.isVersioned() ) {
        final VersionType versionType = (VersionType) model.getHierarchyDetails()
                .getVersioningAttributeBinding()
                .getHibernateTypeDescriptor()
                .getResolvedTypeMapping();

        return versionType.getComparator();
    }

    return null;
}
项目:lams    文件:Binder.java   
private void processHierarchySubEntities(SubclassEntityContainer subclassEntitySource, EntityBinding superEntityBinding) {
    for ( SubclassEntitySource subEntity : subclassEntitySource.subclassEntitySources() ) {
        EntityBinding entityBinding = createEntityBinding( subEntity, superEntityBinding );
        processHierarchySubEntities( subEntity, entityBinding );
    }
}
项目:lams    文件:Binder.java   
private EntityBinding buildBasicEntityBinding(EntitySource entitySource, EntityBinding superEntityBinding) {
    final EntityBinding entityBinding = superEntityBinding == null
            ? new EntityBinding( currentInheritanceType, currentHierarchyEntityMode )
            : new EntityBinding( superEntityBinding );

    final String entityName = entitySource.getEntityName();
    final String className = currentHierarchyEntityMode == EntityMode.POJO ? entitySource.getClassName() : null;

    final Entity entity = new Entity(
            entityName,
            className,
            currentBindingContext.makeClassReference( className ),
            superEntityBinding == null ? null : superEntityBinding.getEntity()
    );
    entityBinding.setEntity( entity );

    entityBinding.setJpaEntityName( entitySource.getJpaEntityName() );

    if ( currentHierarchyEntityMode == EntityMode.POJO ) {
        final String proxy = entitySource.getProxy();
        if ( proxy != null ) {
            entityBinding.setProxyInterfaceType(
                    currentBindingContext.makeClassReference(
                            currentBindingContext.qualifyClassName( proxy )
                    )
            );
            entityBinding.setLazy( true );
        }
        else if ( entitySource.isLazy() ) {
            entityBinding.setProxyInterfaceType( entityBinding.getEntity().getClassReferenceUnresolved() );
            entityBinding.setLazy( true );
        }
    }
    else {
        entityBinding.setProxyInterfaceType( null );
        entityBinding.setLazy( entitySource.isLazy() );
    }

    final String customTuplizerClassName = entitySource.getCustomTuplizerClassName();
    if ( customTuplizerClassName != null ) {
        entityBinding.setCustomEntityTuplizerClass(
                currentBindingContext.<EntityTuplizer>locateClassByName(
                        customTuplizerClassName
                )
        );
    }

    final String customPersisterClassName = entitySource.getCustomPersisterClassName();
    if ( customPersisterClassName != null ) {
        entityBinding.setCustomEntityPersisterClass(
                currentBindingContext.<EntityPersister>locateClassByName(
                        customPersisterClassName
                )
        );
    }

    entityBinding.setMetaAttributeContext( buildMetaAttributeContext( entitySource ) );

    entityBinding.setDynamicUpdate( entitySource.isDynamicUpdate() );
    entityBinding.setDynamicInsert( entitySource.isDynamicInsert() );
    entityBinding.setBatchSize( entitySource.getBatchSize() );
    entityBinding.setSelectBeforeUpdate( entitySource.isSelectBeforeUpdate() );
    entityBinding.setAbstract( entitySource.isAbstract() );

    entityBinding.setCustomLoaderName( entitySource.getCustomLoaderName() );
    entityBinding.setCustomInsert( entitySource.getCustomSqlInsert() );
    entityBinding.setCustomUpdate( entitySource.getCustomSqlUpdate() );
    entityBinding.setCustomDelete( entitySource.getCustomSqlDelete() );

    if ( entitySource.getSynchronizedTableNames() != null ) {
        entityBinding.addSynchronizedTableNames( entitySource.getSynchronizedTableNames() );
    }

    entityBinding.setJpaCallbackClasses(entitySource.getJpaCallbackClasses());

    return entityBinding;
}
项目:lams    文件:Binder.java   
private void bindCollectionTable(
        PluralAttributeSource attributeSource,
        AbstractPluralAttributeBinding pluralAttributeBinding) {
    if ( attributeSource.getElementSource().getNature() == PluralAttributeElementNature.ONE_TO_MANY ) {
        return;
    }

    final Schema.Name schemaName = Helper.determineDatabaseSchemaName(
            attributeSource.getExplicitSchemaName(),
            attributeSource.getExplicitCatalogName(),
            currentBindingContext
    );
    final Schema schema = metadata.getDatabase().locateSchema( schemaName );

    final String tableName = attributeSource.getExplicitCollectionTableName();
    if ( StringHelper.isNotEmpty( tableName ) ) {
        final Identifier tableIdentifier = Identifier.toIdentifier(
                currentBindingContext.getNamingStrategy().tableName( tableName )
        );
        Table collectionTable = schema.locateTable( tableIdentifier );
        if ( collectionTable == null ) {
            collectionTable = schema.createTable( tableIdentifier );
        }
        pluralAttributeBinding.setCollectionTable( collectionTable );
    }
    else {
        // todo : not sure wel have all the needed info here in all cases, specifically when needing to know the "other side"
        final EntityBinding owner = pluralAttributeBinding.getContainer().seekEntityBinding();
        final String ownerTableLogicalName = Table.class.isInstance( owner.getPrimaryTable() )
                ? Table.class.cast( owner.getPrimaryTable() ).getTableName().getName()
                : null;
        String collectionTableName = currentBindingContext.getNamingStrategy().collectionTableName(
                owner.getEntity().getName(),
                ownerTableLogicalName,
                null,   // todo : here
                null,   // todo : and here
                pluralAttributeBinding.getContainer().getPathBase() + '.' + attributeSource.getName()
        );
        collectionTableName = quoteIdentifier( collectionTableName );
        pluralAttributeBinding.setCollectionTable(
                schema.locateOrCreateTable(
                        Identifier.toIdentifier(
                                collectionTableName
                        )
                )
        );
    }

    if ( StringHelper.isNotEmpty( attributeSource.getCollectionTableComment() ) ) {
        pluralAttributeBinding.getCollectionTable().addComment( attributeSource.getCollectionTableComment() );
    }

    if ( StringHelper.isNotEmpty( attributeSource.getCollectionTableCheck() ) ) {
        pluralAttributeBinding.getCollectionTable().addCheckConstraint( attributeSource.getCollectionTableCheck() );
    }

    pluralAttributeBinding.setWhere( attributeSource.getWhere() );
}
项目:lams    文件:Binder.java   
private void bindPrimaryTable(EntitySource entitySource, EntityBinding entityBinding) {
    final TableSource tableSource = entitySource.getPrimaryTable();
    final Table table = createTable( entityBinding, tableSource );
    entityBinding.setPrimaryTable( table );
    entityBinding.setPrimaryTableName( table.getTableName().getName() );
}
项目:lams    文件:Binder.java   
private void bindSecondaryTables(EntitySource entitySource, EntityBinding entityBinding) {
    for ( TableSource secondaryTableSource : entitySource.getSecondaryTables() ) {
        final Table table = createTable( entityBinding, secondaryTableSource );
        entityBinding.addSecondaryTable( secondaryTableSource.getLogicalName(), table );
    }
}
项目:lams    文件:Binder.java   
private void processFetchProfiles(EntitySource entitySource, EntityBinding entityBinding) {
    // todo : process the entity-local fetch-profile declaration
}