Search in sources :

Example 1 with RelationalValueSourceContainer

use of org.hibernate.boot.model.source.spi.RelationalValueSourceContainer in project hibernate-orm by hibernate.

the class ModelBinder method determineTable.

private Identifier determineTable(MappingDocument mappingDocument, SingularAttributeSourceEmbedded embeddedAttributeSource) {
    Identifier tableName = null;
    for (AttributeSource attributeSource : embeddedAttributeSource.getEmbeddableSource().attributeSources()) {
        final Identifier determinedName;
        if (RelationalValueSourceContainer.class.isInstance(attributeSource)) {
            determinedName = determineTable(mappingDocument, embeddedAttributeSource.getAttributeRole().getFullPath(), (RelationalValueSourceContainer) attributeSource);
        } else if (SingularAttributeSourceEmbedded.class.isInstance(attributeSource)) {
            determinedName = determineTable(mappingDocument, (SingularAttributeSourceEmbedded) attributeSource);
        } else if (SingularAttributeSourceAny.class.isInstance(attributeSource)) {
            determinedName = determineTable(mappingDocument, attributeSource.getAttributeRole().getFullPath(), ((SingularAttributeSourceAny) attributeSource).getKeySource().getRelationalValueSources());
        } else {
            continue;
        }
        if (EqualsHelper.equals(tableName, determinedName)) {
            continue;
        }
        if (tableName != null) {
            throw new MappingException(String.format(Locale.ENGLISH, "Attribute [%s] referenced columns from multiple tables: %s, %s", embeddedAttributeSource.getAttributeRole().getFullPath(), tableName, determinedName), mappingDocument.getOrigin());
        }
        tableName = determinedName;
    }
    return tableName;
}
Also used : Identifier(org.hibernate.boot.model.naming.Identifier) 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) RelationalValueSourceContainer(org.hibernate.boot.model.source.spi.RelationalValueSourceContainer) SingularAttributeSourceEmbedded(org.hibernate.boot.model.source.spi.SingularAttributeSourceEmbedded) MappingException(org.hibernate.boot.MappingException)

Aggregations

MappingException (org.hibernate.boot.MappingException)1 Identifier (org.hibernate.boot.model.naming.Identifier)1 AttributeSource (org.hibernate.boot.model.source.spi.AttributeSource)1 PluralAttributeSource (org.hibernate.boot.model.source.spi.PluralAttributeSource)1 RelationalValueSourceContainer (org.hibernate.boot.model.source.spi.RelationalValueSourceContainer)1 SingularAttributeSource (org.hibernate.boot.model.source.spi.SingularAttributeSource)1 SingularAttributeSourceEmbedded (org.hibernate.boot.model.source.spi.SingularAttributeSourceEmbedded)1 VersionAttributeSource (org.hibernate.boot.model.source.spi.VersionAttributeSource)1