Search in sources :

Example 6 with Identifier

use of org.hibernate.boot.model.naming.Identifier in project hibernate-orm by hibernate.

the class ModelBinder method bindAllEntityAttributes.

private void bindAllEntityAttributes(MappingDocument mappingDocument, EntitySource entitySource, PersistentClass entityDescriptor) {
    final EntityTableXref entityTableXref = mappingDocument.getMetadataCollector().getEntityTableXref(entityDescriptor.getEntityName());
    if (entityTableXref == null) {
        throw new AssertionFailure(String.format(Locale.ENGLISH, "Unable to locate EntityTableXref for entity [%s] : %s", entityDescriptor.getEntityName(), mappingDocument.getOrigin()));
    }
    // make sure we bind secondary tables first!
    for (SecondaryTableSource secondaryTableSource : entitySource.getSecondaryTableMap().values()) {
        final Join secondaryTableJoin = new Join();
        secondaryTableJoin.setPersistentClass(entityDescriptor);
        bindSecondaryTable(mappingDocument, secondaryTableSource, secondaryTableJoin, entityTableXref);
        entityDescriptor.addJoin(secondaryTableJoin);
    }
    for (AttributeSource attributeSource : entitySource.attributeSources()) {
        if (PluralAttributeSource.class.isInstance(attributeSource)) {
            // plural attribute
            final Property attribute = createPluralAttribute(mappingDocument, (PluralAttributeSource) attributeSource, entityDescriptor);
            entityDescriptor.addProperty(attribute);
        } else {
            // singular attribute
            if (SingularAttributeSourceBasic.class.isInstance(attributeSource)) {
                final SingularAttributeSourceBasic basicAttributeSource = (SingularAttributeSourceBasic) attributeSource;
                final Identifier tableName = determineTable(mappingDocument, basicAttributeSource.getName(), basicAttributeSource);
                final AttributeContainer attributeContainer;
                final Table table;
                final Join secondaryTableJoin = entityTableXref.locateJoin(tableName);
                if (secondaryTableJoin == null) {
                    table = entityDescriptor.getTable();
                    attributeContainer = entityDescriptor;
                } else {
                    table = secondaryTableJoin.getTable();
                    attributeContainer = secondaryTableJoin;
                }
                final Property attribute = createBasicAttribute(mappingDocument, basicAttributeSource, new SimpleValue(mappingDocument.getMetadataCollector(), table), entityDescriptor.getClassName());
                if (secondaryTableJoin != null) {
                    attribute.setOptional(secondaryTableJoin.isOptional());
                }
                attributeContainer.addProperty(attribute);
                handleNaturalIdBinding(mappingDocument, entityDescriptor, attribute, basicAttributeSource.getNaturalIdMutability());
            } else if (SingularAttributeSourceEmbedded.class.isInstance(attributeSource)) {
                final SingularAttributeSourceEmbedded embeddedAttributeSource = (SingularAttributeSourceEmbedded) attributeSource;
                final Identifier tableName = determineTable(mappingDocument, embeddedAttributeSource);
                final AttributeContainer attributeContainer;
                final Table table;
                final Join secondaryTableJoin = entityTableXref.locateJoin(tableName);
                if (secondaryTableJoin == null) {
                    table = entityDescriptor.getTable();
                    attributeContainer = entityDescriptor;
                } else {
                    table = secondaryTableJoin.getTable();
                    attributeContainer = secondaryTableJoin;
                }
                final Property attribute = createEmbeddedAttribute(mappingDocument, (SingularAttributeSourceEmbedded) attributeSource, new Component(mappingDocument.getMetadataCollector(), table, entityDescriptor), entityDescriptor.getClassName());
                if (secondaryTableJoin != null) {
                    attribute.setOptional(secondaryTableJoin.isOptional());
                }
                attributeContainer.addProperty(attribute);
                handleNaturalIdBinding(mappingDocument, entityDescriptor, attribute, embeddedAttributeSource.getNaturalIdMutability());
            } else if (SingularAttributeSourceManyToOne.class.isInstance(attributeSource)) {
                final SingularAttributeSourceManyToOne manyToOneAttributeSource = (SingularAttributeSourceManyToOne) attributeSource;
                final Identifier tableName = determineTable(mappingDocument, manyToOneAttributeSource.getName(), manyToOneAttributeSource);
                final AttributeContainer attributeContainer;
                final Table table;
                final Join secondaryTableJoin = entityTableXref.locateJoin(tableName);
                if (secondaryTableJoin == null) {
                    table = entityDescriptor.getTable();
                    attributeContainer = entityDescriptor;
                } else {
                    table = secondaryTableJoin.getTable();
                    attributeContainer = secondaryTableJoin;
                }
                final Property attribute = createManyToOneAttribute(mappingDocument, manyToOneAttributeSource, new ManyToOne(mappingDocument.getMetadataCollector(), table), entityDescriptor.getClassName());
                if (secondaryTableJoin != null) {
                    attribute.setOptional(secondaryTableJoin.isOptional());
                }
                attributeContainer.addProperty(attribute);
                handleNaturalIdBinding(mappingDocument, entityDescriptor, attribute, manyToOneAttributeSource.getNaturalIdMutability());
            } else if (SingularAttributeSourceOneToOne.class.isInstance(attributeSource)) {
                final SingularAttributeSourceOneToOne oneToOneAttributeSource = (SingularAttributeSourceOneToOne) attributeSource;
                final Table table = entityDescriptor.getTable();
                final Property attribute = createOneToOneAttribute(mappingDocument, oneToOneAttributeSource, new OneToOne(mappingDocument.getMetadataCollector(), table, entityDescriptor), entityDescriptor.getClassName());
                entityDescriptor.addProperty(attribute);
                handleNaturalIdBinding(mappingDocument, entityDescriptor, attribute, oneToOneAttributeSource.getNaturalIdMutability());
            } else if (SingularAttributeSourceAny.class.isInstance(attributeSource)) {
                final SingularAttributeSourceAny anyAttributeSource = (SingularAttributeSourceAny) attributeSource;
                final Identifier tableName = determineTable(mappingDocument, anyAttributeSource.getName(), anyAttributeSource.getKeySource().getRelationalValueSources());
                final AttributeContainer attributeContainer;
                final Table table;
                final Join secondaryTableJoin = entityTableXref.locateJoin(tableName);
                if (secondaryTableJoin == null) {
                    table = entityDescriptor.getTable();
                    attributeContainer = entityDescriptor;
                } else {
                    table = secondaryTableJoin.getTable();
                    attributeContainer = secondaryTableJoin;
                }
                final Property attribute = createAnyAssociationAttribute(mappingDocument, anyAttributeSource, new Any(mappingDocument.getMetadataCollector(), table), entityDescriptor.getEntityName());
                if (secondaryTableJoin != null) {
                    attribute.setOptional(secondaryTableJoin.isOptional());
                }
                attributeContainer.addProperty(attribute);
                handleNaturalIdBinding(mappingDocument, entityDescriptor, attribute, anyAttributeSource.getNaturalIdMutability());
            }
        }
    }
}
Also used : SingularAttributeSourceBasic(org.hibernate.boot.model.source.spi.SingularAttributeSourceBasic) AssertionFailure(org.hibernate.AssertionFailure) VersionAttributeSource(org.hibernate.boot.model.source.spi.VersionAttributeSource) AttributeSource(org.hibernate.boot.model.source.spi.AttributeSource) PluralAttributeSource(org.hibernate.boot.model.source.spi.PluralAttributeSource) SingularAttributeSource(org.hibernate.boot.model.source.spi.SingularAttributeSource) Table(org.hibernate.mapping.Table) DenormalizedTable(org.hibernate.mapping.DenormalizedTable) SingularAttributeSourceAny(org.hibernate.boot.model.source.spi.SingularAttributeSourceAny) Join(org.hibernate.mapping.Join) SingularAttributeSourceManyToOne(org.hibernate.boot.model.source.spi.SingularAttributeSourceManyToOne) AttributeContainer(org.hibernate.mapping.AttributeContainer) SecondaryTableSource(org.hibernate.boot.model.source.spi.SecondaryTableSource) SingularAttributeSourceOneToOne(org.hibernate.boot.model.source.spi.SingularAttributeSourceOneToOne) PluralAttributeElementSourceManyToAny(org.hibernate.boot.model.source.spi.PluralAttributeElementSourceManyToAny) Any(org.hibernate.mapping.Any) SingularAttributeSourceAny(org.hibernate.boot.model.source.spi.SingularAttributeSourceAny) SingularAttributeSourceEmbedded(org.hibernate.boot.model.source.spi.SingularAttributeSourceEmbedded) SingularAttributeSourceManyToOne(org.hibernate.boot.model.source.spi.SingularAttributeSourceManyToOne) ManyToOne(org.hibernate.mapping.ManyToOne) SimpleValue(org.hibernate.mapping.SimpleValue) OneToOne(org.hibernate.mapping.OneToOne) SingularAttributeSourceOneToOne(org.hibernate.boot.model.source.spi.SingularAttributeSourceOneToOne) Identifier(org.hibernate.boot.model.naming.Identifier) EntityTableXref(org.hibernate.boot.spi.InFlightMetadataCollector.EntityTableXref) Component(org.hibernate.mapping.Component) Property(org.hibernate.mapping.Property) SyntheticProperty(org.hibernate.mapping.SyntheticProperty)

Example 7 with Identifier

use of org.hibernate.boot.model.naming.Identifier in project hibernate-orm by hibernate.

the class ModelBinder method bindBasicEntityValues.

private void bindBasicEntityValues(MappingDocument sourceDocument, AbstractEntitySourceImpl entitySource, PersistentClass entityDescriptor) {
    entityDescriptor.setEntityName(entitySource.getEntityNamingSource().getEntityName());
    entityDescriptor.setJpaEntityName(entitySource.getEntityNamingSource().getJpaEntityName());
    entityDescriptor.setClassName(entitySource.getEntityNamingSource().getClassName());
    entityDescriptor.setDiscriminatorValue(entitySource.getDiscriminatorMatchValue() != null ? entitySource.getDiscriminatorMatchValue() : entityDescriptor.getEntityName());
    // NOTE : entitySource#isLazy already accounts for MappingDefaults#areEntitiesImplicitlyLazy
    if (StringHelper.isNotEmpty(entitySource.getProxy())) {
        final String qualifiedProxyName = sourceDocument.qualifyClassName(entitySource.getProxy());
        entityDescriptor.setProxyInterfaceName(qualifiedProxyName);
        entityDescriptor.setLazy(true);
    } else if (entitySource.isLazy()) {
        entityDescriptor.setProxyInterfaceName(entityDescriptor.getClassName());
        entityDescriptor.setLazy(true);
    } else {
        entityDescriptor.setProxyInterfaceName(null);
        entityDescriptor.setLazy(false);
    }
    entityDescriptor.setAbstract(entitySource.isAbstract());
    sourceDocument.getMetadataCollector().addImport(entitySource.getEntityNamingSource().getEntityName(), entitySource.getEntityNamingSource().getEntityName());
    if (sourceDocument.getMappingDefaults().isAutoImportEnabled() && entitySource.getEntityNamingSource().getEntityName().indexOf('.') > 0) {
        sourceDocument.getMetadataCollector().addImport(StringHelper.unqualify(entitySource.getEntityNamingSource().getEntityName()), entitySource.getEntityNamingSource().getEntityName());
    }
    if (entitySource.getTuplizerClassMap() != null) {
        if (entitySource.getTuplizerClassMap().size() > 1) {
            DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfMultipleEntityModeSupport();
        }
        for (Map.Entry<EntityMode, String> tuplizerEntry : entitySource.getTuplizerClassMap().entrySet()) {
            entityDescriptor.addTuplizer(tuplizerEntry.getKey(), tuplizerEntry.getValue());
        }
    }
    if (StringHelper.isNotEmpty(entitySource.getXmlNodeName())) {
        DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfDomEntityModeSupport();
    }
    entityDescriptor.setDynamicInsert(entitySource.isDynamicInsert());
    entityDescriptor.setDynamicUpdate(entitySource.isDynamicUpdate());
    entityDescriptor.setBatchSize(entitySource.getBatchSize());
    entityDescriptor.setSelectBeforeUpdate(entitySource.isSelectBeforeUpdate());
    if (StringHelper.isNotEmpty(entitySource.getCustomPersisterClassName())) {
        try {
            entityDescriptor.setEntityPersisterClass(sourceDocument.getClassLoaderAccess().classForName(entitySource.getCustomPersisterClassName()));
        } catch (ClassLoadingException e) {
            throw new MappingException(String.format(Locale.ENGLISH, "Unable to load specified persister class : %s", entitySource.getCustomPersisterClassName()), e, sourceDocument.getOrigin());
        }
    }
    bindCustomSql(sourceDocument, entitySource, entityDescriptor);
    final JdbcEnvironment jdbcEnvironment = sourceDocument.getMetadataCollector().getDatabase().getJdbcEnvironment();
    for (String tableName : entitySource.getSynchronizedTableNames()) {
        final Identifier physicalTableName = sourceDocument.getBuildingOptions().getPhysicalNamingStrategy().toPhysicalTableName(jdbcEnvironment.getIdentifierHelper().toIdentifier(tableName), jdbcEnvironment);
        entityDescriptor.addSynchronizedTable(physicalTableName.render(jdbcEnvironment.getDialect()));
    }
    for (FilterSource filterSource : entitySource.getFilterSources()) {
        String condition = filterSource.getCondition();
        if (condition == null) {
            final FilterDefinition filterDefinition = sourceDocument.getMetadataCollector().getFilterDefinition(filterSource.getName());
            if (filterDefinition != null) {
                condition = filterDefinition.getDefaultFilterCondition();
            }
        }
        entityDescriptor.addFilter(filterSource.getName(), condition, filterSource.shouldAutoInjectAliases(), filterSource.getAliasToTableMap(), filterSource.getAliasToEntityMap());
    }
    for (JaxbHbmNamedQueryType namedQuery : entitySource.getNamedQueries()) {
        NamedQueryBinder.processNamedQuery(sourceDocument, namedQuery, entitySource.getEntityNamingSource().getEntityName() + ".");
    }
    for (JaxbHbmNamedNativeQueryType namedQuery : entitySource.getNamedNativeQueries()) {
        NamedQueryBinder.processNamedNativeQuery(sourceDocument, namedQuery, entitySource.getEntityNamingSource().getEntityName() + ".");
    }
    entityDescriptor.setMetaAttributes(entitySource.getToolingHintContext().getMetaAttributeMap());
}
Also used : FilterDefinition(org.hibernate.engine.spi.FilterDefinition) Identifier(org.hibernate.boot.model.naming.Identifier) FilterSource(org.hibernate.boot.model.source.spi.FilterSource) JaxbHbmNamedNativeQueryType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNamedNativeQueryType) JaxbHbmNamedQueryType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNamedQueryType) ClassLoadingException(org.hibernate.boot.registry.classloading.spi.ClassLoadingException) Map(java.util.Map) HashMap(java.util.HashMap) JdbcEnvironment(org.hibernate.engine.jdbc.env.spi.JdbcEnvironment) EntityMode(org.hibernate.EntityMode) MappingException(org.hibernate.boot.MappingException)

Example 8 with Identifier

use of org.hibernate.boot.model.naming.Identifier in project hibernate-orm by hibernate.

the class ModelBinder method bindAny.

private void bindAny(MappingDocument sourceDocument, final AnyMappingSource anyMapping, Any anyBinding, final AttributeRole attributeRole, AttributePath attributePath) {
    final TypeResolution keyTypeResolution = resolveType(sourceDocument, anyMapping.getKeySource().getTypeSource());
    if (keyTypeResolution != null) {
        anyBinding.setIdentifierType(keyTypeResolution.typeName);
    }
    final TypeResolution discriminatorTypeResolution = resolveType(sourceDocument, anyMapping.getDiscriminatorSource().getTypeSource());
    if (discriminatorTypeResolution != null) {
        anyBinding.setMetaType(discriminatorTypeResolution.typeName);
        try {
            final DiscriminatorType metaType = (DiscriminatorType) sourceDocument.getMetadataCollector().getTypeResolver().heuristicType(discriminatorTypeResolution.typeName);
            final HashMap anyValueBindingMap = new HashMap();
            for (Map.Entry<String, String> discriminatorValueMappings : anyMapping.getDiscriminatorSource().getValueMappings().entrySet()) {
                try {
                    final Object discriminatorValue = metaType.stringToObject(discriminatorValueMappings.getKey());
                    final String mappedEntityName = sourceDocument.qualifyClassName(discriminatorValueMappings.getValue());
                    //noinspection unchecked
                    anyValueBindingMap.put(discriminatorValue, mappedEntityName);
                } catch (Exception e) {
                    throw new MappingException(String.format(Locale.ENGLISH, "Unable to interpret <meta-value value=\"%s\" class=\"%s\"/> defined as part of <any/> attribute [%s]", discriminatorValueMappings.getKey(), discriminatorValueMappings.getValue(), attributeRole.getFullPath()), e, sourceDocument.getOrigin());
                }
            }
            anyBinding.setMetaValues(anyValueBindingMap);
        } catch (ClassCastException e) {
            throw new MappingException(String.format(Locale.ENGLISH, "Specified meta-type [%s] for <any/> attribute [%s] did not implement DiscriminatorType", discriminatorTypeResolution.typeName, attributeRole.getFullPath()), e, sourceDocument.getOrigin());
        }
    }
    relationalObjectBinder.bindColumnOrFormula(sourceDocument, anyMapping.getDiscriminatorSource().getRelationalValueSource(), anyBinding, true, new RelationalObjectBinder.ColumnNamingDelegate() {

        @Override
        public Identifier determineImplicitName(LocalMetadataBuildingContext context) {
            return implicitNamingStrategy.determineAnyDiscriminatorColumnName(anyMapping.getDiscriminatorSource());
        }
    });
    relationalObjectBinder.bindColumnsAndFormulas(sourceDocument, anyMapping.getKeySource().getRelationalValueSources(), anyBinding, true, new RelationalObjectBinder.ColumnNamingDelegate() {

        @Override
        public Identifier determineImplicitName(LocalMetadataBuildingContext context) {
            return implicitNamingStrategy.determineAnyKeyColumnName(anyMapping.getKeySource());
        }
    });
}
Also used : HashMap(java.util.HashMap) MappingException(org.hibernate.boot.MappingException) ClassLoadingException(org.hibernate.boot.registry.classloading.spi.ClassLoadingException) MappingException(org.hibernate.boot.MappingException) Identifier(org.hibernate.boot.model.naming.Identifier) DiscriminatorType(org.hibernate.type.DiscriminatorType) LocalMetadataBuildingContext(org.hibernate.boot.model.source.spi.LocalMetadataBuildingContext) Map(java.util.Map) HashMap(java.util.HashMap)

Example 9 with Identifier

use of org.hibernate.boot.model.naming.Identifier in project hibernate-orm by hibernate.

the class ModelBinder method bindSimpleEntityIdentifier.

private void bindSimpleEntityIdentifier(MappingDocument sourceDocument, final EntityHierarchySourceImpl hierarchySource, RootClass rootEntityDescriptor) {
    final IdentifierSourceSimple idSource = (IdentifierSourceSimple) hierarchySource.getIdentifierSource();
    final SimpleValue idValue = new SimpleValue(sourceDocument.getMetadataCollector(), rootEntityDescriptor.getTable());
    rootEntityDescriptor.setIdentifier(idValue);
    bindSimpleValueType(sourceDocument, idSource.getIdentifierAttributeSource().getTypeInformation(), idValue);
    final String propertyName = idSource.getIdentifierAttributeSource().getName();
    if (propertyName == null || !rootEntityDescriptor.hasPojoRepresentation()) {
        if (!idValue.isTypeSpecified()) {
            throw new MappingException("must specify an identifier type: " + rootEntityDescriptor.getEntityName(), sourceDocument.getOrigin());
        }
    } else {
        idValue.setTypeUsingReflection(rootEntityDescriptor.getClassName(), propertyName);
    }
    relationalObjectBinder.bindColumnsAndFormulas(sourceDocument, ((RelationalValueSourceContainer) idSource.getIdentifierAttributeSource()).getRelationalValueSources(), idValue, false, new RelationalObjectBinder.ColumnNamingDelegate() {

        @Override
        public Identifier determineImplicitName(final LocalMetadataBuildingContext context) {
            context.getBuildingOptions().getImplicitNamingStrategy().determineIdentifierColumnName(new ImplicitIdentifierColumnNameSource() {

                @Override
                public EntityNaming getEntityNaming() {
                    return hierarchySource.getRoot().getEntityNamingSource();
                }

                @Override
                public AttributePath getIdentifierAttributePath() {
                    return idSource.getIdentifierAttributeSource().getAttributePath();
                }

                @Override
                public MetadataBuildingContext getBuildingContext() {
                    return context;
                }
            });
            return database.toIdentifier(propertyName);
        }
    });
    if (propertyName != null) {
        Property prop = new Property();
        prop.setValue(idValue);
        bindProperty(sourceDocument, idSource.getIdentifierAttributeSource(), prop);
        rootEntityDescriptor.setIdentifierProperty(prop);
        rootEntityDescriptor.setDeclaredIdentifierProperty(prop);
    }
    makeIdentifier(sourceDocument, idSource.getIdentifierGeneratorDescriptor(), idSource.getUnsavedValue(), idValue);
}
Also used : ImplicitIdentifierColumnNameSource(org.hibernate.boot.model.naming.ImplicitIdentifierColumnNameSource) Identifier(org.hibernate.boot.model.naming.Identifier) IdentifierSourceSimple(org.hibernate.boot.model.source.spi.IdentifierSourceSimple) LocalMetadataBuildingContext(org.hibernate.boot.model.source.spi.LocalMetadataBuildingContext) Property(org.hibernate.mapping.Property) SyntheticProperty(org.hibernate.mapping.SyntheticProperty) SimpleValue(org.hibernate.mapping.SimpleValue) MappingException(org.hibernate.boot.MappingException)

Example 10 with Identifier

use of org.hibernate.boot.model.naming.Identifier in project hibernate-orm by hibernate.

the class ModelBinder method bindEntityTableSpecification.

private Table bindEntityTableSpecification(final MappingDocument mappingDocument, TableSpecificationSource tableSpecSource, Table denormalizedSuperTable, final EntitySource entitySource, PersistentClass entityDescriptor) {
    final Namespace namespace = database.locateNamespace(determineCatalogName(tableSpecSource), determineSchemaName(tableSpecSource));
    final boolean isTable = TableSource.class.isInstance(tableSpecSource);
    final boolean isAbstract = entityDescriptor.isAbstract() == null ? false : entityDescriptor.isAbstract();
    final String subselect;
    final Identifier logicalTableName;
    final Table table;
    if (isTable) {
        final TableSource tableSource = (TableSource) tableSpecSource;
        if (StringHelper.isNotEmpty(tableSource.getExplicitTableName())) {
            logicalTableName = database.toIdentifier(tableSource.getExplicitTableName());
        } else {
            final ImplicitEntityNameSource implicitNamingSource = new ImplicitEntityNameSource() {

                @Override
                public EntityNaming getEntityNaming() {
                    return entitySource.getEntityNamingSource();
                }

                @Override
                public MetadataBuildingContext getBuildingContext() {
                    return mappingDocument;
                }
            };
            logicalTableName = mappingDocument.getBuildingOptions().getImplicitNamingStrategy().determinePrimaryTableName(implicitNamingSource);
        }
        if (denormalizedSuperTable == null) {
            table = namespace.createTable(logicalTableName, isAbstract);
        } else {
            table = namespace.createDenormalizedTable(logicalTableName, isAbstract, denormalizedSuperTable);
        }
    } else {
        final InLineViewSource inLineViewSource = (InLineViewSource) tableSpecSource;
        subselect = inLineViewSource.getSelectStatement();
        logicalTableName = database.toIdentifier(inLineViewSource.getLogicalName());
        if (denormalizedSuperTable == null) {
            table = new Table(namespace, subselect, isAbstract);
        } else {
            table = new DenormalizedTable(namespace, subselect, isAbstract, denormalizedSuperTable);
        }
        table.setName(logicalTableName.render());
    }
    EntityTableXref superEntityTableXref = null;
    if (entitySource.getSuperType() != null) {
        //noinspection SuspiciousMethodCalls
        final String superEntityName = ((EntitySource) entitySource.getSuperType()).getEntityNamingSource().getEntityName();
        superEntityTableXref = mappingDocument.getMetadataCollector().getEntityTableXref(superEntityName);
        if (superEntityTableXref == null) {
            throw new MappingException(String.format(Locale.ENGLISH, "Unable to locate entity table xref for entity [%s] super-type [%s]", entityDescriptor.getEntityName(), superEntityName), mappingDocument.getOrigin());
        }
    }
    mappingDocument.getMetadataCollector().addEntityTableXref(entitySource.getEntityNamingSource().getEntityName(), logicalTableName, table, superEntityTableXref);
    if (isTable) {
        final TableSource tableSource = (TableSource) tableSpecSource;
        table.setRowId(tableSource.getRowId());
        if (StringHelper.isNotEmpty(tableSource.getCheckConstraint())) {
            table.addCheckConstraint(tableSource.getCheckConstraint());
        }
    }
    table.setComment(tableSpecSource.getComment());
    mappingDocument.getMetadataCollector().addTableNameBinding(logicalTableName, table);
    return table;
}
Also used : Identifier(org.hibernate.boot.model.naming.Identifier) Table(org.hibernate.mapping.Table) DenormalizedTable(org.hibernate.mapping.DenormalizedTable) TableSource(org.hibernate.boot.model.source.spi.TableSource) SecondaryTableSource(org.hibernate.boot.model.source.spi.SecondaryTableSource) DenormalizedTable(org.hibernate.mapping.DenormalizedTable) EntityTableXref(org.hibernate.boot.spi.InFlightMetadataCollector.EntityTableXref) ImplicitEntityNameSource(org.hibernate.boot.model.naming.ImplicitEntityNameSource) InLineViewSource(org.hibernate.boot.model.source.spi.InLineViewSource) Namespace(org.hibernate.boot.model.relational.Namespace) MappingException(org.hibernate.boot.MappingException)

Aggregations

Identifier (org.hibernate.boot.model.naming.Identifier)46 Table (org.hibernate.mapping.Table)15 LocalMetadataBuildingContext (org.hibernate.boot.model.source.spi.LocalMetadataBuildingContext)10 DenormalizedTable (org.hibernate.mapping.DenormalizedTable)9 SimpleValue (org.hibernate.mapping.SimpleValue)9 HashMap (java.util.HashMap)7 MappingException (org.hibernate.boot.MappingException)7 Namespace (org.hibernate.boot.model.relational.Namespace)7 Database (org.hibernate.boot.model.relational.Database)6 ResultSet (java.sql.ResultSet)5 SQLException (java.sql.SQLException)5 ArrayList (java.util.ArrayList)5 DatabaseIdentifier (org.hibernate.boot.model.naming.DatabaseIdentifier)5 Column (org.hibernate.mapping.Column)5 Property (org.hibernate.mapping.Property)5 HashSet (java.util.HashSet)4 DuplicateMappingException (org.hibernate.DuplicateMappingException)4 ImplicitNamingStrategy (org.hibernate.boot.model.naming.ImplicitNamingStrategy)4 JdbcEnvironment (org.hibernate.engine.jdbc.env.spi.JdbcEnvironment)4 SyntheticProperty (org.hibernate.mapping.SyntheticProperty)4