mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-08 12:14:47 +00:00
HHH-6480 - Develop component binding for new metamodel
This commit is contained in:
parent
e540089783
commit
91f84c2303
@ -1,114 +0,0 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.binding;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.metamodel.domain.PluralAttribute;
|
||||
import org.hibernate.metamodel.domain.SingularAttribute;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractAttributeBindingContainer implements AttributeBindingContainer {
|
||||
private Map<String, AttributeBinding> attributeBindingMap = new HashMap<String, AttributeBinding>();
|
||||
|
||||
protected void registerAttributeBinding(String name, AttributeBinding attributeBinding) {
|
||||
attributeBindingMap.put( name, attributeBinding );
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleSingularAttributeBinding makeSimpleAttributeBinding(SingularAttribute attribute) {
|
||||
return makeSimpleAttributeBinding( attribute, false, false );
|
||||
}
|
||||
|
||||
private SimpleSingularAttributeBinding makeSimpleAttributeBinding(SingularAttribute attribute, boolean forceNonNullable, boolean forceUnique) {
|
||||
final SimpleSingularAttributeBinding binding = new SimpleSingularAttributeBinding(
|
||||
this,
|
||||
attribute,
|
||||
forceNonNullable,
|
||||
forceUnique
|
||||
);
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentAttributeBinding makeComponentAttributeBinding(SingularAttribute attribute) {
|
||||
final ComponentAttributeBinding binding = new ComponentAttributeBinding( this, attribute );
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManyToOneAttributeBinding makeManyToOneAttributeBinding(SingularAttribute attribute) {
|
||||
final ManyToOneAttributeBinding binding = new ManyToOneAttributeBinding( this, attribute );
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BagBinding makeBagAttributeBinding(PluralAttribute attribute, CollectionElementNature nature) {
|
||||
final BagBinding binding = new BagBinding( this, attribute, nature );
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeBinding locateAttributeBinding(String name) {
|
||||
return attributeBindingMap.get( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AttributeBinding> attributeBindings() {
|
||||
return attributeBindingMap.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of attribute bindings defined on this class, including the
|
||||
* identifier attribute binding and attribute bindings defined
|
||||
* as part of a join.
|
||||
*
|
||||
* @return The number of attribute bindings
|
||||
*/
|
||||
public int getAttributeBindingClosureSpan() {
|
||||
// TODO: fix this after HHH-6337 is fixed; for now just return size of attributeBindingMap
|
||||
// if this is not a root, then need to include the superclass attribute bindings
|
||||
return attributeBindingMap.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attribute bindings defined on this class, including the
|
||||
* identifier attribute binding and attribute bindings defined
|
||||
* as part of a join.
|
||||
*
|
||||
* @return The attribute bindings.
|
||||
*/
|
||||
public Iterable<AttributeBinding> getAttributeBindingClosure() {
|
||||
// TODO: fix this after HHH-6337 is fixed. for now, just return attributeBindings
|
||||
// if this is not a root, then need to include the superclass attribute bindings
|
||||
return attributeBindings();
|
||||
}
|
||||
}
|
@ -26,36 +26,101 @@
|
||||
import org.hibernate.metamodel.domain.AttributeContainer;
|
||||
import org.hibernate.metamodel.domain.PluralAttribute;
|
||||
import org.hibernate.metamodel.domain.SingularAttribute;
|
||||
import org.hibernate.metamodel.relational.TableSpecification;
|
||||
import org.hibernate.metamodel.source.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* Common contract for {@link EntityBinding} and {@link ComponentAttributeBinding} in so far as they are both
|
||||
* containers for {@link AttributeBinding} descriptors
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface AttributeBindingContainer {
|
||||
/**
|
||||
* Obtain the path base of this container. Intended to help uniquely identify each attribute binding.
|
||||
*
|
||||
* @return The path base for this container.
|
||||
*/
|
||||
public String getPathBase();
|
||||
|
||||
/**
|
||||
* Obtain the underlying domain attribute container.
|
||||
*
|
||||
* @return The attribute container
|
||||
*/
|
||||
public AttributeContainer getAttributeContainer();
|
||||
|
||||
/**
|
||||
* Obtain all attribute bindings
|
||||
*
|
||||
* @return All attribute bindings
|
||||
*/
|
||||
public Iterable<AttributeBinding> attributeBindings();
|
||||
|
||||
/**
|
||||
* Locate a specific attribute binding, by its local name.
|
||||
*
|
||||
* @param name The name of the attribute, local to this container.
|
||||
*
|
||||
* @return The attribute binding.
|
||||
*/
|
||||
public AttributeBinding locateAttributeBinding(String name);
|
||||
|
||||
public SimpleSingularAttributeBinding makeSimpleAttributeBinding(SingularAttribute attribute);
|
||||
/**
|
||||
* Factory method for basic attribute bindings.
|
||||
*
|
||||
* @param attribute The attribute for which to make a binding.
|
||||
*
|
||||
* @return The attribute binding instance.
|
||||
*/
|
||||
public BasicAttributeBinding makeBasicAttributeBinding(SingularAttribute attribute);
|
||||
|
||||
/**
|
||||
* Factory method for component attribute bindings.
|
||||
*
|
||||
* @param attribute The attribute for which to make a binding.
|
||||
*
|
||||
* @return The attribute binding instance.
|
||||
*/
|
||||
public ComponentAttributeBinding makeComponentAttributeBinding(SingularAttribute attribute);
|
||||
|
||||
/**
|
||||
* Factory method for many-to-one attribute bindings.
|
||||
*
|
||||
* @param attribute The attribute for which to make a binding.
|
||||
*
|
||||
* @return The attribute binding instance.
|
||||
*/
|
||||
public ManyToOneAttributeBinding makeManyToOneAttributeBinding(SingularAttribute attribute);
|
||||
|
||||
/**
|
||||
* Factory method for bag attribute bindings.
|
||||
*
|
||||
* @param attribute The attribute for which to make a binding.
|
||||
* @param nature The nature of the collection elements.
|
||||
*
|
||||
* @return The attribute binding instance.
|
||||
*/
|
||||
public BagBinding makeBagAttributeBinding(PluralAttribute attribute, CollectionElementNature nature);
|
||||
|
||||
/**
|
||||
* Seeks out the entity binding that is the root of this component path.
|
||||
*
|
||||
* @return The entity binding
|
||||
*/
|
||||
public EntityBinding seekEntityBinding();
|
||||
|
||||
public TableSpecification getPrimaryTable();
|
||||
|
||||
public TableSpecification locateTable(String containingTableName);
|
||||
|
||||
/**
|
||||
* Obtain the {@link Class} reference for this attribute container. Generally this is used to perform reflection
|
||||
* on the attributes.
|
||||
*
|
||||
* @return The {@link Class} reference
|
||||
*/
|
||||
public Class<?> getClassReference();
|
||||
|
||||
/**
|
||||
* Obtain the meta-attribute context for this container.
|
||||
*
|
||||
* @return The meta-attribute context.
|
||||
*/
|
||||
public MetaAttributeContext getMetaAttributeContext();
|
||||
}
|
||||
|
@ -41,7 +41,7 @@
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class SimpleSingularAttributeBinding
|
||||
public class BasicAttributeBinding
|
||||
extends AbstractSingularAttributeBinding
|
||||
implements SingularAttributeBinding, KeyValueBinding {
|
||||
|
||||
@ -55,7 +55,7 @@ public class SimpleSingularAttributeBinding
|
||||
|
||||
private MetaAttributeContext metaAttributeContext;
|
||||
|
||||
SimpleSingularAttributeBinding(
|
||||
BasicAttributeBinding(
|
||||
AttributeBindingContainer container,
|
||||
SingularAttribute attribute,
|
||||
boolean forceNonNullable,
|
@ -38,7 +38,7 @@ public class CollectionKey {
|
||||
private HibernateTypeDescriptor hibernateTypeDescriptor;
|
||||
|
||||
// todo : this would be nice to have but we do not always know it, especially in HBM case.
|
||||
// private SimpleSingularAttributeBinding otherSide;
|
||||
// private BasicAttributeBinding otherSide;
|
||||
|
||||
public CollectionKey(AbstractPluralAttributeBinding collection) {
|
||||
this.collection = collection;
|
||||
|
@ -31,7 +31,6 @@
|
||||
import org.hibernate.metamodel.domain.Component;
|
||||
import org.hibernate.metamodel.domain.PluralAttribute;
|
||||
import org.hibernate.metamodel.domain.SingularAttribute;
|
||||
import org.hibernate.metamodel.relational.TableSpecification;
|
||||
import org.hibernate.metamodel.source.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
@ -83,16 +82,6 @@ public void setMetaAttributeContext(MetaAttributeContext metaAttributeContext) {
|
||||
this.metaAttributeContext = metaAttributeContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableSpecification getPrimaryTable() {
|
||||
return getContainer().getPrimaryTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableSpecification locateTable(String containingTableName) {
|
||||
return getContainer().locateTable( containingTableName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeBinding locateAttributeBinding(String name) {
|
||||
return attributeBindingMap.get( name );
|
||||
@ -109,8 +98,8 @@ protected void checkValueBinding() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleSingularAttributeBinding makeSimpleAttributeBinding(SingularAttribute attribute) {
|
||||
final SimpleSingularAttributeBinding binding = new SimpleSingularAttributeBinding(
|
||||
public BasicAttributeBinding makeBasicAttributeBinding(SingularAttribute attribute) {
|
||||
final BasicAttributeBinding binding = new BasicAttributeBinding(
|
||||
this,
|
||||
attribute,
|
||||
isNullable(),
|
||||
|
@ -34,6 +34,8 @@
|
||||
import org.hibernate.internal.util.Value;
|
||||
import org.hibernate.metamodel.domain.AttributeContainer;
|
||||
import org.hibernate.metamodel.domain.Entity;
|
||||
import org.hibernate.metamodel.domain.PluralAttribute;
|
||||
import org.hibernate.metamodel.domain.SingularAttribute;
|
||||
import org.hibernate.metamodel.relational.TableSpecification;
|
||||
import org.hibernate.metamodel.source.MetaAttributeContext;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
@ -46,12 +48,12 @@
|
||||
* @author Hardy Ferentschik
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class EntityBinding extends AbstractAttributeBindingContainer {
|
||||
public class EntityBinding implements AttributeBindingContainer {
|
||||
private final EntityBinding superEntityBinding;
|
||||
private final HierarchyDetails hierarchyDetails;
|
||||
|
||||
private Entity entity;
|
||||
private TableSpecification baseTable;
|
||||
private TableSpecification primaryTable;
|
||||
private Map<String, TableSpecification> secondaryTables = new HashMap<String, TableSpecification>();
|
||||
|
||||
private Value<Class<?>> proxyInterfaceType;
|
||||
@ -88,6 +90,7 @@ public class EntityBinding extends AbstractAttributeBindingContainer {
|
||||
private CustomSQL customDelete;
|
||||
|
||||
private Set<String> synchronizedTableNames = new HashSet<String>();
|
||||
private Map<String, AttributeBinding> attributeBindingMap = new HashMap<String, AttributeBinding>();
|
||||
|
||||
/**
|
||||
* Used to instantiate the EntityBinding for an entity that is the root of an inheritance hierarchy
|
||||
@ -131,18 +134,17 @@ public void setEntity(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableSpecification getPrimaryTable() {
|
||||
return baseTable;
|
||||
return primaryTable;
|
||||
}
|
||||
|
||||
public void setBaseTable(TableSpecification baseTable) {
|
||||
this.baseTable = baseTable;
|
||||
public void setPrimaryTable(TableSpecification primaryTable) {
|
||||
this.primaryTable = primaryTable;
|
||||
}
|
||||
|
||||
public TableSpecification locateTable(String tableName) {
|
||||
if ( tableName == null ) {
|
||||
return baseTable;
|
||||
return primaryTable;
|
||||
}
|
||||
|
||||
TableSpecification tableSpec = secondaryTables.get( tableName );
|
||||
@ -200,12 +202,11 @@ public AttributeContainer getAttributeContainer() {
|
||||
return getEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerAttributeBinding(String name, AttributeBinding attributeBinding) {
|
||||
if ( SingularAssociationAttributeBinding.class.isInstance( attributeBinding ) ) {
|
||||
entityReferencingAttributeBindings.add( (SingularAssociationAttributeBinding) attributeBinding );
|
||||
}
|
||||
super.registerAttributeBinding( name, attributeBinding );
|
||||
attributeBindingMap.put( name, attributeBinding );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -378,4 +379,77 @@ public String toString() {
|
||||
sb.append( '}' );
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicAttributeBinding makeBasicAttributeBinding(SingularAttribute attribute) {
|
||||
return makeSimpleAttributeBinding( attribute, false, false );
|
||||
}
|
||||
|
||||
private BasicAttributeBinding makeSimpleAttributeBinding(SingularAttribute attribute, boolean forceNonNullable, boolean forceUnique) {
|
||||
final BasicAttributeBinding binding = new BasicAttributeBinding(
|
||||
this,
|
||||
attribute,
|
||||
forceNonNullable,
|
||||
forceUnique
|
||||
);
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentAttributeBinding makeComponentAttributeBinding(SingularAttribute attribute) {
|
||||
final ComponentAttributeBinding binding = new ComponentAttributeBinding( this, attribute );
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManyToOneAttributeBinding makeManyToOneAttributeBinding(SingularAttribute attribute) {
|
||||
final ManyToOneAttributeBinding binding = new ManyToOneAttributeBinding( this, attribute );
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BagBinding makeBagAttributeBinding(PluralAttribute attribute, CollectionElementNature nature) {
|
||||
final BagBinding binding = new BagBinding( this, attribute, nature );
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeBinding locateAttributeBinding(String name) {
|
||||
return attributeBindingMap.get( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AttributeBinding> attributeBindings() {
|
||||
return attributeBindingMap.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of attribute bindings defined on this class, including the
|
||||
* identifier attribute binding and attribute bindings defined
|
||||
* as part of a join.
|
||||
*
|
||||
* @return The number of attribute bindings
|
||||
*/
|
||||
public int getAttributeBindingClosureSpan() {
|
||||
// TODO: fix this after HHH-6337 is fixed; for now just return size of attributeBindingMap
|
||||
// if this is not a root, then need to include the superclass attribute bindings
|
||||
return attributeBindingMap.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attribute bindings defined on this class, including the
|
||||
* identifier attribute binding and attribute bindings defined
|
||||
* as part of a join.
|
||||
*
|
||||
* @return The attribute bindings.
|
||||
*/
|
||||
public Iterable<AttributeBinding> getAttributeBindingClosure() {
|
||||
// TODO: fix this after HHH-6337 is fixed. for now, just return attributeBindings
|
||||
// if this is not a root, then need to include the superclass attribute bindings
|
||||
return attributeBindings();
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@
|
||||
*/
|
||||
public class EntityIdentifier {
|
||||
private final EntityBinding entityBinding;
|
||||
private SimpleSingularAttributeBinding attributeBinding;
|
||||
private BasicAttributeBinding attributeBinding;
|
||||
private IdentifierGenerator identifierGenerator;
|
||||
private IdGenerator idGenerator;
|
||||
private boolean isIdentifierMapper = false;
|
||||
@ -52,11 +52,11 @@ public EntityIdentifier(EntityBinding entityBinding) {
|
||||
this.entityBinding = entityBinding;
|
||||
}
|
||||
|
||||
public SimpleSingularAttributeBinding getValueBinding() {
|
||||
public BasicAttributeBinding getValueBinding() {
|
||||
return attributeBinding;
|
||||
}
|
||||
|
||||
public void setValueBinding(SimpleSingularAttributeBinding attributeBinding) {
|
||||
public void setValueBinding(BasicAttributeBinding attributeBinding) {
|
||||
if ( this.attributeBinding != null ) {
|
||||
throw new AssertionFailure(
|
||||
String.format(
|
||||
|
@ -39,7 +39,7 @@ public class HierarchyDetails {
|
||||
private EntityDiscriminator entityDiscriminator;
|
||||
|
||||
private OptimisticLockStyle optimisticLockStyle;
|
||||
private SimpleSingularAttributeBinding versioningAttributeBinding;
|
||||
private BasicAttributeBinding versioningAttributeBinding;
|
||||
|
||||
private Caching caching;
|
||||
|
||||
@ -84,11 +84,11 @@ public void setEntityDiscriminator(EntityDiscriminator entityDiscriminator) {
|
||||
this.entityDiscriminator = entityDiscriminator;
|
||||
}
|
||||
|
||||
public SimpleSingularAttributeBinding getVersioningAttributeBinding() {
|
||||
public BasicAttributeBinding getVersioningAttributeBinding() {
|
||||
return versioningAttributeBinding;
|
||||
}
|
||||
|
||||
public void setVersioningAttributeBinding(SimpleSingularAttributeBinding versioningAttributeBinding) {
|
||||
public void setVersioningAttributeBinding(BasicAttributeBinding versioningAttributeBinding) {
|
||||
this.versioningAttributeBinding = versioningAttributeBinding;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
* @author Gail Badner
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ManyToOneAttributeBinding extends SimpleSingularAttributeBinding implements SingularAssociationAttributeBinding {
|
||||
public class ManyToOneAttributeBinding extends BasicAttributeBinding implements SingularAssociationAttributeBinding {
|
||||
private String referencedEntityName;
|
||||
private String referencedAttributeName;
|
||||
private AttributeBinding referencedAttributeBinding;
|
||||
|
@ -37,6 +37,7 @@
|
||||
import org.hibernate.metamodel.binding.AbstractPluralAttributeBinding;
|
||||
import org.hibernate.metamodel.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.binding.AttributeBindingContainer;
|
||||
import org.hibernate.metamodel.binding.BasicAttributeBinding;
|
||||
import org.hibernate.metamodel.binding.CollectionElementNature;
|
||||
import org.hibernate.metamodel.binding.ComponentAttributeBinding;
|
||||
import org.hibernate.metamodel.binding.EntityBinding;
|
||||
@ -44,7 +45,6 @@
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
import org.hibernate.metamodel.binding.ManyToOneAttributeBinding;
|
||||
import org.hibernate.metamodel.binding.MetaAttribute;
|
||||
import org.hibernate.metamodel.binding.SimpleSingularAttributeBinding;
|
||||
import org.hibernate.metamodel.binding.SimpleValueBinding;
|
||||
import org.hibernate.metamodel.binding.SingularAttributeBinding;
|
||||
import org.hibernate.metamodel.binding.TypeDef;
|
||||
@ -268,7 +268,7 @@ else if ( entitySource.isLazy() ) {
|
||||
private EntityBinding makeDiscriminatedSubclassBinding(SubclassEntitySource entitySource, EntityBinding superEntityBinding) {
|
||||
final EntityBinding entityBinding = buildBasicEntityBinding( entitySource, superEntityBinding );
|
||||
|
||||
entityBinding.setBaseTable( superEntityBinding.getPrimaryTable() );
|
||||
entityBinding.setPrimaryTable( superEntityBinding.getPrimaryTable() );
|
||||
|
||||
bindDiscriminatorValue( entitySource, entityBinding );
|
||||
|
||||
@ -318,7 +318,7 @@ private void bindIdentifier(RootEntitySource entitySource, EntityBinding entityB
|
||||
}
|
||||
|
||||
private void bindSimpleIdentifier(SimpleIdentifierSource identifierSource, EntityBinding entityBinding) {
|
||||
final SimpleSingularAttributeBinding idAttributeBinding = doBasicSingularAttributeBindingCreation(
|
||||
final BasicAttributeBinding idAttributeBinding = doBasicSingularAttributeBindingCreation(
|
||||
identifierSource.getIdentifierAttributeSource(), entityBinding
|
||||
);
|
||||
|
||||
@ -351,7 +351,7 @@ private void bindVersion(EntityBinding entityBinding, RootEntitySource entitySou
|
||||
return;
|
||||
}
|
||||
|
||||
SimpleSingularAttributeBinding attributeBinding = doBasicSingularAttributeBindingCreation(
|
||||
BasicAttributeBinding attributeBinding = doBasicSingularAttributeBindingCreation(
|
||||
versioningAttributeSource, entityBinding
|
||||
);
|
||||
entityBinding.getHierarchyDetails().setVersioningAttributeBinding( attributeBinding );
|
||||
@ -468,7 +468,7 @@ private CollectionElementNature convert(PluralAttributeElementNature pluralAttri
|
||||
return CollectionElementNature.valueOf( pluralAttributeElementNature.name() );
|
||||
}
|
||||
|
||||
private SimpleSingularAttributeBinding doBasicSingularAttributeBindingCreation(
|
||||
private BasicAttributeBinding doBasicSingularAttributeBindingCreation(
|
||||
SingularAttributeSource attributeSource,
|
||||
AttributeBindingContainer attributeBindingContainer) {
|
||||
final SingularAttribute existingAttribute = attributeBindingContainer.getAttributeContainer().locateSingularAttribute( attributeSource.getName() );
|
||||
@ -483,9 +483,9 @@ else if ( attributeSource.isVirtualAttribute() ) {
|
||||
attribute = attributeBindingContainer.getAttributeContainer().createSingularAttribute( attributeSource.getName() );
|
||||
}
|
||||
|
||||
final SimpleSingularAttributeBinding attributeBinding;
|
||||
final BasicAttributeBinding attributeBinding;
|
||||
if ( attributeSource.getNature() == SingularAttributeNature.BASIC ) {
|
||||
attributeBinding = attributeBindingContainer.makeSimpleAttributeBinding( attribute );
|
||||
attributeBinding = attributeBindingContainer.makeBasicAttributeBinding( attribute );
|
||||
resolveTypeInformation( attributeSource.getTypeInformation(), attributeBinding );
|
||||
}
|
||||
else if ( attributeSource.getNature() == SingularAttributeNature.MANY_TO_ONE ) {
|
||||
@ -521,7 +521,7 @@ else if ( attributeSource.getNature() == SingularAttributeNature.MANY_TO_ONE ) {
|
||||
return attributeBinding;
|
||||
}
|
||||
|
||||
private void resolveTypeInformation(ExplicitHibernateTypeSource typeSource, SimpleSingularAttributeBinding attributeBinding) {
|
||||
private void resolveTypeInformation(ExplicitHibernateTypeSource typeSource, BasicAttributeBinding attributeBinding) {
|
||||
final Class<?> attributeJavaType = determineJavaType( attributeBinding.getAttribute() );
|
||||
if ( attributeJavaType != null ) {
|
||||
attributeBinding.getHibernateTypeDescriptor().setJavaTypeName( attributeJavaType.getName() );
|
||||
@ -640,7 +640,7 @@ private static MetaAttributeContext buildMetaAttributeContext(
|
||||
private void bindPrimaryTable(EntitySource entitySource, EntityBinding entityBinding) {
|
||||
final TableSource tableSource = entitySource.getPrimaryTable();
|
||||
final Table table = createTable( entityBinding, tableSource );
|
||||
entityBinding.setBaseTable( table );
|
||||
entityBinding.setPrimaryTable( table );
|
||||
}
|
||||
|
||||
private void bindSecondaryTables(EntitySource entitySource, EntityBinding entityBinding) {
|
||||
@ -709,6 +709,7 @@ private void bindRelationalValues(
|
||||
if ( relationalValueSourceContainer.relationalValueSources().size() > 0 ) {
|
||||
for ( RelationalValueSource valueSource : relationalValueSourceContainer.relationalValueSources() ) {
|
||||
final TableSpecification table = attributeBinding.getContainer()
|
||||
.seekEntityBinding()
|
||||
.locateTable( valueSource.getContainingTableName() );
|
||||
|
||||
if ( ColumnSource.class.isInstance( valueSource ) ) {
|
||||
@ -737,7 +738,7 @@ private void bindRelationalValues(
|
||||
.propertyToColumnName( attributeBinding.getAttribute().getName() );
|
||||
valueBindings.add(
|
||||
new SimpleValueBinding(
|
||||
attributeBinding.getContainer().getPrimaryTable().locateOrCreateColumn( name )
|
||||
attributeBinding.getContainer().seekEntityBinding().getPrimaryTable().locateOrCreateColumn( name )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@
|
||||
import org.hibernate.metamodel.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.binding.AbstractPluralAttributeBinding;
|
||||
import org.hibernate.metamodel.binding.SimpleSingularAttributeBinding;
|
||||
import org.hibernate.metamodel.binding.BasicAttributeBinding;
|
||||
import org.hibernate.metamodel.binding.SimpleValueBinding;
|
||||
import org.hibernate.metamodel.binding.SingularAttributeBinding;
|
||||
import org.hibernate.property.Getter;
|
||||
@ -109,7 +109,7 @@ public static IdentifierProperty buildIdentifierProperty(PersistentClass mappedE
|
||||
*/
|
||||
public static IdentifierProperty buildIdentifierProperty(EntityBinding mappedEntity, IdentifierGenerator generator) {
|
||||
|
||||
final SimpleSingularAttributeBinding property = mappedEntity.getHierarchyDetails().getEntityIdentifier().getValueBinding();
|
||||
final BasicAttributeBinding property = mappedEntity.getHierarchyDetails().getEntityIdentifier().getValueBinding();
|
||||
|
||||
// TODO: the following will cause an NPE with "virtual" IDs; how should they be set?
|
||||
// (steve) virtual attributes will still be attributes, they will simply be marked as virtual.
|
||||
@ -192,7 +192,7 @@ public static VersionProperty buildVersionProperty(Property property, boolean la
|
||||
* @param lazyAvailable Is property lazy loading currently available.
|
||||
* @return The appropriate VersionProperty definition.
|
||||
*/
|
||||
public static VersionProperty buildVersionProperty(SimpleSingularAttributeBinding property, boolean lazyAvailable) {
|
||||
public static VersionProperty buildVersionProperty(BasicAttributeBinding property, boolean lazyAvailable) {
|
||||
String mappedUnsavedValue = ( (KeyValue) property.getValue() ).getNullValue();
|
||||
|
||||
VersionValue unsavedValue = UnsavedValueFactory.getUnsavedVersionValue(
|
||||
|
@ -51,8 +51,8 @@
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.binding.BasicAttributeBinding;
|
||||
import org.hibernate.metamodel.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.binding.SimpleSingularAttributeBinding;
|
||||
import org.hibernate.metamodel.domain.Attribute;
|
||||
import org.hibernate.metamodel.domain.SingularAttribute;
|
||||
import org.hibernate.tuple.IdentifierProperty;
|
||||
@ -386,8 +386,8 @@ public EntityMetamodel(EntityBinding entityBinding, SessionFactoryImplementor se
|
||||
boolean hasLazy = false;
|
||||
|
||||
// TODO: Fix after HHH-6337 is fixed; for now assume entityBinding is the root binding
|
||||
//SimpleSingularAttributeBinding rootEntityIdentifier = entityBinding.getRootEntityBinding().getEntityIdentifier().getValueBinding();
|
||||
SimpleSingularAttributeBinding rootEntityIdentifier = entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding();
|
||||
//BasicAttributeBinding rootEntityIdentifier = entityBinding.getRootEntityBinding().getEntityIdentifier().getValueBinding();
|
||||
BasicAttributeBinding rootEntityIdentifier = entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding();
|
||||
// entityBinding.getAttributeClosureSpan() includes the identifier binding;
|
||||
// "properties" here excludes the ID, so subtract 1 if the identifier binding is non-null
|
||||
propertySpan = rootEntityIdentifier == null ?
|
||||
|
@ -141,7 +141,7 @@ public void testSimpleEntityWithSimpleComponentMapping() {
|
||||
assertNotNull( componentAttributeBinding );
|
||||
assertSame( componentAttributeBinding.getAttribute().getSingularAttributeType(), componentAttributeBinding.getAttributeContainer() );
|
||||
assertEquals( SimpleEntityWithSimpleComponent.class.getName() + ".simpleComponent", componentAttributeBinding.getPathBase() );
|
||||
assertSame( entityBinding.getPrimaryTable(), componentAttributeBinding.getPrimaryTable() );
|
||||
assertSame( entityBinding, componentAttributeBinding.seekEntityBinding() );
|
||||
assertNotNull( componentAttributeBinding.getComponent() );
|
||||
}
|
||||
|
||||
|
@ -58,10 +58,10 @@ public void testBasicMiddleOutBuilding() {
|
||||
Entity entity = new Entity( "TheEntity", "NoSuchClass", makeJavaType( "NoSuchClass" ), null );
|
||||
EntityBinding entityBinding = new EntityBinding( InheritanceType.NO_INHERITANCE, EntityMode.POJO );
|
||||
entityBinding.setEntity( entity );
|
||||
entityBinding.setBaseTable( table );
|
||||
entityBinding.setPrimaryTable( table );
|
||||
|
||||
SingularAttribute idAttribute = entity.createSingularAttribute( "id" );
|
||||
SimpleSingularAttributeBinding attributeBinding = entityBinding.makeSimpleAttributeBinding( idAttribute );
|
||||
BasicAttributeBinding attributeBinding = entityBinding.makeBasicAttributeBinding( idAttribute );
|
||||
attributeBinding.getHibernateTypeDescriptor().setExplicitTypeName( "long" );
|
||||
assertSame( idAttribute, attributeBinding.getAttribute() );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user