HHH-6471 - Redesign how EntityBinding models hierarchy-shared information
This commit is contained in:
parent
8639904969
commit
46102a2be3
|
@ -96,10 +96,10 @@ public class CacheDataDescriptionImpl implements CacheDataDescription {
|
||||||
Comparator versionComparator = null;
|
Comparator versionComparator = null;
|
||||||
if ( model.isVersioned() ) {
|
if ( model.isVersioned() ) {
|
||||||
versionComparator = (
|
versionComparator = (
|
||||||
( VersionType ) model
|
( VersionType ) model.getHierarchyDetails()
|
||||||
.getVersioningValueBinding()
|
.getVersioningAttributeBinding()
|
||||||
.getHibernateTypeDescriptor()
|
.getHibernateTypeDescriptor()
|
||||||
.getResolvedTypeMapping()
|
.getResolvedTypeMapping()
|
||||||
).getComparator();
|
).getComparator();
|
||||||
}
|
}
|
||||||
return versionComparator;
|
return versionComparator;
|
||||||
|
|
|
@ -605,7 +605,7 @@ public final class SessionFactoryImpl
|
||||||
if ( entityBinding.isRoot() ) {
|
if ( entityBinding.isRoot() ) {
|
||||||
identifierGenerators.put(
|
identifierGenerators.put(
|
||||||
entityBinding.getEntity().getName(),
|
entityBinding.getEntity().getName(),
|
||||||
entityBinding.getEntityIdentifier().getIdentifierGenerator()
|
entityBinding.getHierarchyDetails().getEntityIdentifier().getIdentifierGenerator()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -632,13 +632,13 @@ public final class SessionFactoryImpl
|
||||||
EntityBinding rootEntityBinding = metadata.getRootEntityBinding( model.getEntity().getName() );
|
EntityBinding rootEntityBinding = metadata.getRootEntityBinding( model.getEntity().getName() );
|
||||||
EntityRegionAccessStrategy accessStrategy = null;
|
EntityRegionAccessStrategy accessStrategy = null;
|
||||||
if ( settings.isSecondLevelCacheEnabled() &&
|
if ( settings.isSecondLevelCacheEnabled() &&
|
||||||
rootEntityBinding.getCaching() != null &&
|
rootEntityBinding.getHierarchyDetails().getCaching() != null &&
|
||||||
model.getCaching() != null &&
|
model.getHierarchyDetails().getCaching() != null &&
|
||||||
model.getCaching().getAccessType() != null ) {
|
model.getHierarchyDetails().getCaching().getAccessType() != null ) {
|
||||||
final String cacheRegionName = cacheRegionPrefix + rootEntityBinding.getCaching().getRegion();
|
final String cacheRegionName = cacheRegionPrefix + rootEntityBinding.getHierarchyDetails().getCaching().getRegion();
|
||||||
accessStrategy = EntityRegionAccessStrategy.class.cast( entityAccessStrategies.get( cacheRegionName ) );
|
accessStrategy = EntityRegionAccessStrategy.class.cast( entityAccessStrategies.get( cacheRegionName ) );
|
||||||
if ( accessStrategy == null ) {
|
if ( accessStrategy == null ) {
|
||||||
final AccessType accessType = model.getCaching().getAccessType();
|
final AccessType accessType = model.getHierarchyDetails().getCaching().getAccessType();
|
||||||
LOG.trace("Building cache for entity data [" + model.getEntity().getName() + "]");
|
LOG.trace("Building cache for entity data [" + model.getEntity().getName() + "]");
|
||||||
EntityRegion entityRegion =
|
EntityRegion entityRegion =
|
||||||
settings.getRegionFactory().buildEntityRegion(
|
settings.getRegionFactory().buildEntityRegion(
|
||||||
|
|
|
@ -117,7 +117,7 @@ public abstract class AbstractAttributeBinding implements AttributeBinding {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final boolean isPrimaryKey() {
|
protected final boolean isPrimaryKey() {
|
||||||
return this == getEntityBinding().getEntityIdentifier().getValueBinding();
|
return this == getEntityBinding().getHierarchyDetails().getEntityIdentifier().getValueBinding();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,7 +29,6 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.hibernate.EntityMode;
|
import org.hibernate.EntityMode;
|
||||||
import org.hibernate.engine.OptimisticLockStyle;
|
|
||||||
import org.hibernate.engine.spi.FilterDefinition;
|
import org.hibernate.engine.spi.FilterDefinition;
|
||||||
import org.hibernate.internal.util.Value;
|
import org.hibernate.internal.util.Value;
|
||||||
import org.hibernate.metamodel.domain.Entity;
|
import org.hibernate.metamodel.domain.Entity;
|
||||||
|
@ -48,10 +47,12 @@ import org.hibernate.tuple.entity.EntityTuplizer;
|
||||||
* @author Gail Badner
|
* @author Gail Badner
|
||||||
*/
|
*/
|
||||||
public class EntityBinding {
|
public class EntityBinding {
|
||||||
|
private final EntityBinding superEntityBinding;
|
||||||
|
private final HierarchyDetails hierarchyDetails;
|
||||||
|
|
||||||
private Entity entity;
|
private Entity entity;
|
||||||
private TableSpecification baseTable;
|
private TableSpecification baseTable;
|
||||||
|
|
||||||
private EntityMode entityMode;
|
|
||||||
private Value<Class<?>> proxyInterfaceType;
|
private Value<Class<?>> proxyInterfaceType;
|
||||||
|
|
||||||
private String jpaEntityName;
|
private String jpaEntityName;
|
||||||
|
@ -59,26 +60,33 @@ public class EntityBinding {
|
||||||
private Class<? extends EntityPersister> customEntityPersisterClass;
|
private Class<? extends EntityPersister> customEntityPersisterClass;
|
||||||
private Class<? extends EntityTuplizer> customEntityTuplizerClass;
|
private Class<? extends EntityTuplizer> customEntityTuplizerClass;
|
||||||
|
|
||||||
private InheritanceType entityInheritanceType;
|
private String discriminatorMatchValue;
|
||||||
private EntityBinding superEntityBinding;
|
|
||||||
|
|
||||||
private final EntityIdentifier entityIdentifier = new EntityIdentifier( this );
|
|
||||||
private EntityDiscriminator entityDiscriminator;
|
|
||||||
private String discriminatorValue;
|
|
||||||
private SimpleSingularAttributeBinding versionBinding;
|
|
||||||
|
|
||||||
private Map<String, AttributeBinding> attributeBindingMap = new HashMap<String, AttributeBinding>();
|
private Map<String, AttributeBinding> attributeBindingMap = new HashMap<String, AttributeBinding>();
|
||||||
|
|
||||||
private Set<FilterDefinition> filterDefinitions = new HashSet<FilterDefinition>();
|
private Set<FilterDefinition> filterDefinitions = new HashSet<FilterDefinition>();
|
||||||
private Set<SingularAssociationAttributeBinding> entityReferencingAttributeBindings = new HashSet<SingularAssociationAttributeBinding>();
|
private Set<SingularAssociationAttributeBinding> entityReferencingAttributeBindings = new HashSet<SingularAssociationAttributeBinding>();
|
||||||
|
|
||||||
private Caching caching;
|
/**
|
||||||
|
* Used to instantiate the EntityBinding for an entity that is the root of an inheritance hierarchy
|
||||||
|
*
|
||||||
|
* @param inheritanceType The inheritance type for the hierarchy
|
||||||
|
* @param entityMode The entity mode used in this hierarchy.
|
||||||
|
*/
|
||||||
|
public EntityBinding(InheritanceType inheritanceType, EntityMode entityMode) {
|
||||||
|
this.superEntityBinding = null;
|
||||||
|
this.hierarchyDetails = new HierarchyDetails( this, inheritanceType, entityMode );
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityBinding(EntityBinding superEntityBinding) {
|
||||||
|
this.superEntityBinding = superEntityBinding;
|
||||||
|
this.hierarchyDetails = superEntityBinding.getHierarchyDetails();
|
||||||
|
}
|
||||||
|
|
||||||
private MetaAttributeContext metaAttributeContext;
|
private MetaAttributeContext metaAttributeContext;
|
||||||
|
|
||||||
private boolean lazy;
|
private boolean lazy;
|
||||||
private boolean mutable;
|
private boolean mutable;
|
||||||
private boolean explicitPolymorphism;
|
|
||||||
private String whereFilter;
|
private String whereFilter;
|
||||||
private String rowId;
|
private String rowId;
|
||||||
|
|
||||||
|
@ -88,7 +96,6 @@ public class EntityBinding {
|
||||||
private int batchSize;
|
private int batchSize;
|
||||||
private boolean selectBeforeUpdate;
|
private boolean selectBeforeUpdate;
|
||||||
private boolean hasSubselectLoadableCollections;
|
private boolean hasSubselectLoadableCollections;
|
||||||
private OptimisticLockStyle optimisticLockStyle;
|
|
||||||
|
|
||||||
private Boolean isAbstract;
|
private Boolean isAbstract;
|
||||||
|
|
||||||
|
@ -99,6 +106,19 @@ public class EntityBinding {
|
||||||
|
|
||||||
private Set<String> synchronizedTableNames = new HashSet<String>();
|
private Set<String> synchronizedTableNames = new HashSet<String>();
|
||||||
|
|
||||||
|
|
||||||
|
public HierarchyDetails getHierarchyDetails() {
|
||||||
|
return hierarchyDetails;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityBinding getSuperEntityBinding() {
|
||||||
|
return superEntityBinding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRoot() {
|
||||||
|
return superEntityBinding == null;
|
||||||
|
}
|
||||||
|
|
||||||
public Entity getEntity() {
|
public Entity getEntity() {
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
@ -120,56 +140,12 @@ public class EntityBinding {
|
||||||
return baseTable;
|
return baseTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRoot() {
|
|
||||||
return superEntityBinding == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInheritanceType(InheritanceType entityInheritanceType) {
|
|
||||||
this.entityInheritanceType = entityInheritanceType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InheritanceType getInheritanceType() {
|
|
||||||
return entityInheritanceType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSuperEntityBinding(EntityBinding superEntityBinding) {
|
|
||||||
this.superEntityBinding = superEntityBinding;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityBinding getSuperEntityBinding() {
|
|
||||||
return superEntityBinding;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityIdentifier getEntityIdentifier() {
|
|
||||||
return entityIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityDiscriminator getEntityDiscriminator() {
|
|
||||||
return entityDiscriminator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEntityDiscriminator(EntityDiscriminator entityDiscriminator) {
|
|
||||||
this.entityDiscriminator = entityDiscriminator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDiscriminatorValue() {
|
|
||||||
return discriminatorValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDiscriminatorValue(String discriminatorValue) {
|
|
||||||
this.discriminatorValue = discriminatorValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isVersioned() {
|
public boolean isVersioned() {
|
||||||
return versionBinding != null;
|
return getHierarchyDetails().getVersioningAttributeBinding() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVersionBinding(SimpleSingularAttributeBinding versionBinding) {
|
public String getDiscriminatorMatchValue() {
|
||||||
this.versionBinding = versionBinding;
|
return discriminatorMatchValue;
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleSingularAttributeBinding getVersioningValueBinding() {
|
|
||||||
return versionBinding;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<AttributeBinding> getAttributeBindings() {
|
public Iterable<AttributeBinding> getAttributeBindings() {
|
||||||
|
@ -254,14 +230,6 @@ public class EntityBinding {
|
||||||
attributeBindingMap.put( name, attributeBinding );
|
attributeBindingMap.put( name, attributeBinding );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Caching getCaching() {
|
|
||||||
return caching;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCaching(Caching caching) {
|
|
||||||
this.caching = caching;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MetaAttributeContext getMetaAttributeContext() {
|
public MetaAttributeContext getMetaAttributeContext() {
|
||||||
return metaAttributeContext;
|
return metaAttributeContext;
|
||||||
}
|
}
|
||||||
|
@ -302,14 +270,6 @@ public class EntityBinding {
|
||||||
this.whereFilter = whereFilter;
|
this.whereFilter = whereFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExplicitPolymorphism() {
|
|
||||||
return explicitPolymorphism;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExplicitPolymorphism(boolean explicitPolymorphism) {
|
|
||||||
this.explicitPolymorphism = explicitPolymorphism;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRowId() {
|
public String getRowId() {
|
||||||
return rowId;
|
return rowId;
|
||||||
}
|
}
|
||||||
|
@ -359,14 +319,6 @@ public class EntityBinding {
|
||||||
this.hasSubselectLoadableCollections = hasSubselectLoadableCollections;
|
this.hasSubselectLoadableCollections = hasSubselectLoadableCollections;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OptimisticLockStyle getOptimisticLockStyle() {
|
|
||||||
return optimisticLockStyle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOptimisticLockStyle(OptimisticLockStyle optimisticLockStyle) {
|
|
||||||
this.optimisticLockStyle = optimisticLockStyle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class<? extends EntityPersister> getCustomEntityPersisterClass() {
|
public Class<? extends EntityPersister> getCustomEntityPersisterClass() {
|
||||||
return customEntityPersisterClass;
|
return customEntityPersisterClass;
|
||||||
}
|
}
|
||||||
|
@ -399,14 +351,6 @@ public class EntityBinding {
|
||||||
this.synchronizedTableNames.addAll( synchronizedTableNames );
|
this.synchronizedTableNames.addAll( synchronizedTableNames );
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityMode getEntityMode() {
|
|
||||||
return entityMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEntityMode(EntityMode entityMode) {
|
|
||||||
this.entityMode = entityMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getJpaEntityName() {
|
public String getJpaEntityName() {
|
||||||
return jpaEntityName;
|
return jpaEntityName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
/*
|
||||||
|
* 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 org.hibernate.EntityMode;
|
||||||
|
import org.hibernate.engine.OptimisticLockStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class HierarchyDetails {
|
||||||
|
private final EntityBinding rootEntityBinding;
|
||||||
|
private final InheritanceType inheritanceType;
|
||||||
|
private final EntityMode entityMode;
|
||||||
|
|
||||||
|
private final EntityIdentifier entityIdentifier;
|
||||||
|
|
||||||
|
private EntityDiscriminator entityDiscriminator;
|
||||||
|
|
||||||
|
private OptimisticLockStyle optimisticLockStyle;
|
||||||
|
private SimpleSingularAttributeBinding versioningAttributeBinding;
|
||||||
|
|
||||||
|
private Caching caching;
|
||||||
|
|
||||||
|
private boolean explicitPolymorphism;
|
||||||
|
|
||||||
|
public HierarchyDetails(EntityBinding rootEntityBinding, InheritanceType inheritanceType, EntityMode entityMode) {
|
||||||
|
this.rootEntityBinding = rootEntityBinding;
|
||||||
|
this.inheritanceType = inheritanceType;
|
||||||
|
this.entityMode = entityMode;
|
||||||
|
this.entityIdentifier = new EntityIdentifier( rootEntityBinding );
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityBinding getRootEntityBinding() {
|
||||||
|
return rootEntityBinding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InheritanceType getInheritanceType() {
|
||||||
|
return inheritanceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityMode getEntityMode() {
|
||||||
|
return entityMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityIdentifier getEntityIdentifier() {
|
||||||
|
return entityIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityDiscriminator getEntityDiscriminator() {
|
||||||
|
return entityDiscriminator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OptimisticLockStyle getOptimisticLockStyle() {
|
||||||
|
return optimisticLockStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOptimisticLockStyle(OptimisticLockStyle optimisticLockStyle) {
|
||||||
|
this.optimisticLockStyle = optimisticLockStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntityDiscriminator(EntityDiscriminator entityDiscriminator) {
|
||||||
|
this.entityDiscriminator = entityDiscriminator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleSingularAttributeBinding getVersioningAttributeBinding() {
|
||||||
|
return versioningAttributeBinding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersioningAttributeBinding(SimpleSingularAttributeBinding versioningAttributeBinding) {
|
||||||
|
this.versioningAttributeBinding = versioningAttributeBinding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Caching getCaching() {
|
||||||
|
return caching;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCaching(Caching caching) {
|
||||||
|
this.caching = caching;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExplicitPolymorphism() {
|
||||||
|
return explicitPolymorphism;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExplicitPolymorphism(boolean explicitPolymorphism) {
|
||||||
|
this.explicitPolymorphism = explicitPolymorphism;
|
||||||
|
}
|
||||||
|
}
|
|
@ -171,23 +171,22 @@ public class Binder {
|
||||||
bindVersion( entityBinding, entitySource );
|
bindVersion( entityBinding, entitySource );
|
||||||
bindDiscriminator( entitySource, entityBinding );
|
bindDiscriminator( entitySource, entityBinding );
|
||||||
|
|
||||||
|
entityBinding.getHierarchyDetails().setCaching( entitySource.getCaching() );
|
||||||
|
entityBinding.getHierarchyDetails().setExplicitPolymorphism( entitySource.isExplicitPolymorphism() );
|
||||||
|
entityBinding.getHierarchyDetails().setOptimisticLockStyle( entitySource.getOptimisticLockStyle() );
|
||||||
|
|
||||||
entityBinding.setMutable( entitySource.isMutable() );
|
entityBinding.setMutable( entitySource.isMutable() );
|
||||||
entityBinding.setExplicitPolymorphism( entitySource.isExplicitPolymorphism() );
|
|
||||||
entityBinding.setWhereFilter( entitySource.getWhere() );
|
entityBinding.setWhereFilter( entitySource.getWhere() );
|
||||||
entityBinding.setRowId( entitySource.getRowId() );
|
entityBinding.setRowId( entitySource.getRowId() );
|
||||||
entityBinding.setOptimisticLockStyle( entitySource.getOptimisticLockStyle() );
|
|
||||||
entityBinding.setCaching( entitySource.getCaching() );
|
|
||||||
|
|
||||||
return entityBinding;
|
return entityBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private EntityBinding buildBasicEntityBinding(EntitySource entitySource, EntityBinding superEntityBinding) {
|
private EntityBinding buildBasicEntityBinding(EntitySource entitySource, EntityBinding superEntityBinding) {
|
||||||
final EntityBinding entityBinding = new EntityBinding();
|
final EntityBinding entityBinding = superEntityBinding == null
|
||||||
entityBinding.setSuperEntityBinding( superEntityBinding );
|
? new EntityBinding( currentInheritanceType, currentHierarchyEntityMode )
|
||||||
entityBinding.setInheritanceType( currentInheritanceType );
|
: new EntityBinding( superEntityBinding );
|
||||||
|
|
||||||
entityBinding.setEntityMode( currentHierarchyEntityMode );
|
|
||||||
|
|
||||||
final String entityName = entitySource.getEntityName();
|
final String entityName = entitySource.getEntityName();
|
||||||
final String className = currentHierarchyEntityMode == EntityMode.POJO ? entitySource.getClassName() : null;
|
final String className = currentHierarchyEntityMode == EntityMode.POJO ? entitySource.getClassName() : null;
|
||||||
|
@ -202,7 +201,7 @@ public class Binder {
|
||||||
|
|
||||||
entityBinding.setJpaEntityName( entitySource.getJpaEntityName() );
|
entityBinding.setJpaEntityName( entitySource.getJpaEntityName() );
|
||||||
|
|
||||||
if ( entityBinding.getEntityMode() == EntityMode.POJO ) {
|
if ( currentHierarchyEntityMode == EntityMode.POJO ) {
|
||||||
final String proxy = entitySource.getProxy();
|
final String proxy = entitySource.getProxy();
|
||||||
if ( proxy != null ) {
|
if ( proxy != null ) {
|
||||||
entityBinding.setProxyInterfaceType(
|
entityBinding.setProxyInterfaceType(
|
||||||
|
@ -317,8 +316,8 @@ public class Binder {
|
||||||
identifierSource.getIdentifierAttributeSource(), entityBinding
|
identifierSource.getIdentifierAttributeSource(), entityBinding
|
||||||
);
|
);
|
||||||
|
|
||||||
entityBinding.getEntityIdentifier().setValueBinding( idAttributeBinding );
|
entityBinding.getHierarchyDetails().getEntityIdentifier().setValueBinding( idAttributeBinding );
|
||||||
entityBinding.getEntityIdentifier().setIdGenerator( identifierSource.getIdentifierGeneratorDescriptor() );
|
entityBinding.getHierarchyDetails().getEntityIdentifier().setIdGenerator( identifierSource.getIdentifierGeneratorDescriptor() );
|
||||||
|
|
||||||
final org.hibernate.metamodel.relational.Value relationalValue = idAttributeBinding.getValue();
|
final org.hibernate.metamodel.relational.Value relationalValue = idAttributeBinding.getValue();
|
||||||
|
|
||||||
|
@ -347,7 +346,7 @@ public class Binder {
|
||||||
SimpleSingularAttributeBinding attributeBinding = doBasicSingularAttributeBindingCreation(
|
SimpleSingularAttributeBinding attributeBinding = doBasicSingularAttributeBindingCreation(
|
||||||
versioningAttributeSource, entityBinding
|
versioningAttributeSource, entityBinding
|
||||||
);
|
);
|
||||||
entityBinding.setVersionBinding( attributeBinding );
|
entityBinding.getHierarchyDetails().setVersioningAttributeBinding( attributeBinding );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindDiscriminator(RootEntitySource entitySource, EntityBinding entityBinding) {
|
private void bindDiscriminator(RootEntitySource entitySource, EntityBinding entityBinding) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ class AssociationResolver {
|
||||||
AttributeBinding referencedAttributeBinding =
|
AttributeBinding referencedAttributeBinding =
|
||||||
attributeBinding.isPropertyReference() ?
|
attributeBinding.isPropertyReference() ?
|
||||||
entityBinding.getAttributeBinding( attributeBinding.getReferencedAttributeName() ) :
|
entityBinding.getAttributeBinding( attributeBinding.getReferencedAttributeName() ) :
|
||||||
entityBinding.getEntityIdentifier().getValueBinding();
|
entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding();
|
||||||
if ( referencedAttributeBinding == null ) {
|
if ( referencedAttributeBinding == null ) {
|
||||||
// TODO: does attribute name include path w/ entity name?
|
// TODO: does attribute name include path w/ entity name?
|
||||||
throw new MappingException(
|
throw new MappingException(
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class IdentifierGeneratorResolver {
|
||||||
new ObjectNameNormalizerImpl( metadata )
|
new ObjectNameNormalizerImpl( metadata )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
entityBinding.getEntityIdentifier().createIdentifierGenerator(
|
entityBinding.getHierarchyDetails().getEntityIdentifier().createIdentifierGenerator(
|
||||||
metadata.getIdentifierGeneratorFactory(),
|
metadata.getIdentifierGeneratorFactory(),
|
||||||
properties
|
properties
|
||||||
);
|
);
|
||||||
|
|
|
@ -511,6 +511,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
||||||
throw new MappingException( "Entity binding not known: " + entityName );
|
throw new MappingException( "Entity binding not known: " + entityName );
|
||||||
}
|
}
|
||||||
return entityBinding
|
return entityBinding
|
||||||
|
.getHierarchyDetails()
|
||||||
.getEntityIdentifier()
|
.getEntityIdentifier()
|
||||||
.getValueBinding()
|
.getValueBinding()
|
||||||
.getHibernateTypeDescriptor()
|
.getHibernateTypeDescriptor()
|
||||||
|
@ -523,7 +524,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
||||||
if ( entityBinding == null ) {
|
if ( entityBinding == null ) {
|
||||||
throw new MappingException( "Entity binding not known: " + entityName );
|
throw new MappingException( "Entity binding not known: " + entityName );
|
||||||
}
|
}
|
||||||
AttributeBinding idBinding = entityBinding.getEntityIdentifier().getValueBinding();
|
AttributeBinding idBinding = entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding();
|
||||||
return idBinding == null ? null : idBinding.getAttribute().getName();
|
return idBinding == null ? null : idBinding.getAttribute().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -772,9 +772,9 @@ public abstract class AbstractEntityPersister
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
this.cacheAccessStrategy = cacheAccessStrategy;
|
this.cacheAccessStrategy = cacheAccessStrategy;
|
||||||
this.isLazyPropertiesCacheable =
|
this.isLazyPropertiesCacheable =
|
||||||
entityBinding.getCaching() == null ?
|
entityBinding.getHierarchyDetails().getCaching() == null ?
|
||||||
false :
|
false :
|
||||||
entityBinding.getCaching().isCacheLazyProperties();
|
entityBinding.getHierarchyDetails().getCaching().isCacheLazyProperties();
|
||||||
this.cacheEntryStructure =
|
this.cacheEntryStructure =
|
||||||
factory.getSettings().isStructuredCacheEntriesEnabled() ?
|
factory.getSettings().isStructuredCacheEntriesEnabled() ?
|
||||||
new StructuredCacheEntry(this) :
|
new StructuredCacheEntry(this) :
|
||||||
|
@ -791,7 +791,7 @@ public abstract class AbstractEntityPersister
|
||||||
|
|
||||||
// IDENTIFIER
|
// IDENTIFIER
|
||||||
|
|
||||||
identifierColumnSpan = entityBinding.getEntityIdentifier().getValueBinding().getSimpleValueSpan();
|
identifierColumnSpan = entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding().getSimpleValueSpan();
|
||||||
rootTableKeyColumnNames = new String[identifierColumnSpan];
|
rootTableKeyColumnNames = new String[identifierColumnSpan];
|
||||||
rootTableKeyColumnReaders = new String[identifierColumnSpan];
|
rootTableKeyColumnReaders = new String[identifierColumnSpan];
|
||||||
rootTableKeyColumnReaderTemplates = new String[identifierColumnSpan];
|
rootTableKeyColumnReaderTemplates = new String[identifierColumnSpan];
|
||||||
|
@ -821,7 +821,7 @@ public abstract class AbstractEntityPersister
|
||||||
// VERSION
|
// VERSION
|
||||||
|
|
||||||
if ( entityBinding.isVersioned() ) {
|
if ( entityBinding.isVersioned() ) {
|
||||||
final Value versioningValue = entityBinding.getVersioningValueBinding().getValue();
|
final Value versioningValue = entityBinding.getHierarchyDetails().getVersioningAttributeBinding().getValue();
|
||||||
if ( ! org.hibernate.metamodel.relational.Column.class.isInstance( versioningValue ) ) {
|
if ( ! org.hibernate.metamodel.relational.Column.class.isInstance( versioningValue ) ) {
|
||||||
throw new AssertionFailure( "Bad versioning attribute binding : " + versioningValue );
|
throw new AssertionFailure( "Bad versioning attribute binding : " + versioningValue );
|
||||||
}
|
}
|
||||||
|
@ -864,7 +864,7 @@ public abstract class AbstractEntityPersister
|
||||||
i = 0;
|
i = 0;
|
||||||
boolean foundFormula = false;
|
boolean foundFormula = false;
|
||||||
for ( AttributeBinding attributeBinding : entityBinding.getAttributeBindingClosure() ) {
|
for ( AttributeBinding attributeBinding : entityBinding.getAttributeBindingClosure() ) {
|
||||||
if ( attributeBinding == entityBinding.getEntityIdentifier().getValueBinding() ) {
|
if ( attributeBinding == entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding() ) {
|
||||||
// entity identifier is not considered a "normal" property
|
// entity identifier is not considered a "normal" property
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -970,7 +970,7 @@ public abstract class AbstractEntityPersister
|
||||||
// TODO: fix this when EntityBinding.getSubclassAttributeBindingClosure() is working
|
// TODO: fix this when EntityBinding.getSubclassAttributeBindingClosure() is working
|
||||||
// for ( AttributeBinding prop : entityBinding.getSubclassAttributeBindingClosure() ) {
|
// for ( AttributeBinding prop : entityBinding.getSubclassAttributeBindingClosure() ) {
|
||||||
for ( AttributeBinding attributeBinding : entityBinding.getAttributeBindingClosure() ) {
|
for ( AttributeBinding attributeBinding : entityBinding.getAttributeBindingClosure() ) {
|
||||||
if ( attributeBinding == entityBinding.getEntityIdentifier().getValueBinding() ) {
|
if ( attributeBinding == entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding() ) {
|
||||||
// entity identifier is not considered a "normal" property
|
// entity identifier is not considered a "normal" property
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -548,11 +548,11 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
final Object discriminatorValue;
|
final Object discriminatorValue;
|
||||||
if ( isPolymorphic ) {
|
if ( isPolymorphic ) {
|
||||||
org.hibernate.metamodel.relational.Value discrimValue =
|
org.hibernate.metamodel.relational.Value discrimValue =
|
||||||
entityBinding.getEntityDiscriminator().getValueBinding().getValue();
|
entityBinding.getHierarchyDetails().getEntityDiscriminator().getValueBinding().getValue();
|
||||||
if (discrimValue==null) {
|
if (discrimValue==null) {
|
||||||
throw new MappingException("discriminator mapping required for single table polymorphic persistence");
|
throw new MappingException("discriminator mapping required for single table polymorphic persistence");
|
||||||
}
|
}
|
||||||
forceDiscriminator = entityBinding.getEntityDiscriminator().isForced();
|
forceDiscriminator = entityBinding.getHierarchyDetails().getEntityDiscriminator().isForced();
|
||||||
if ( ! SimpleValue.class.isInstance( discrimValue ) ) {
|
if ( ! SimpleValue.class.isInstance( discrimValue ) ) {
|
||||||
throw new MappingException( "discriminator must be mapped to a single column or formula." );
|
throw new MappingException( "discriminator must be mapped to a single column or formula." );
|
||||||
}
|
}
|
||||||
|
@ -585,6 +585,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
}
|
}
|
||||||
discriminatorType =
|
discriminatorType =
|
||||||
entityBinding
|
entityBinding
|
||||||
|
.getHierarchyDetails()
|
||||||
.getEntityDiscriminator()
|
.getEntityDiscriminator()
|
||||||
.getValueBinding()
|
.getValueBinding()
|
||||||
.getHibernateTypeDescriptor()
|
.getHibernateTypeDescriptor()
|
||||||
|
@ -606,7 +607,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
discriminatorInsertable =
|
discriminatorInsertable =
|
||||||
entityBinding.getEntityDiscriminator().isInserted() &&
|
entityBinding.getHierarchyDetails().getEntityDiscriminator().isInserted() &&
|
||||||
! DerivedValue.class.isInstance( discrimValue );
|
! DerivedValue.class.isInstance( discrimValue );
|
||||||
try {
|
try {
|
||||||
DiscriminatorType dtype = ( DiscriminatorType ) discriminatorType;
|
DiscriminatorType dtype = ( DiscriminatorType ) discriminatorType;
|
||||||
|
@ -642,7 +643,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
for( AttributeBinding attributeBinding : entityBinding.getAttributeBindingClosure() ) {
|
for( AttributeBinding attributeBinding : entityBinding.getAttributeBindingClosure() ) {
|
||||||
// TODO: fix when joins are working (HHH-6391)
|
// TODO: fix when joins are working (HHH-6391)
|
||||||
//propertyTableNumbers[i++] = entityBinding.getJoinNumber( attributeBinding);
|
//propertyTableNumbers[i++] = entityBinding.getJoinNumber( attributeBinding);
|
||||||
if ( attributeBinding == entityBinding.getEntityIdentifier().getValueBinding() ) {
|
if ( attributeBinding == entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding() ) {
|
||||||
continue; // skip identifier binding
|
continue; // skip identifier binding
|
||||||
}
|
}
|
||||||
if ( ! attributeBinding.getAttribute().isSingular() ) {
|
if ( ! attributeBinding.getAttribute().isSingular() ) {
|
||||||
|
|
|
@ -47,12 +47,10 @@ import org.hibernate.persister.spi.UnknownPersisterException;
|
||||||
public class StandardPersisterClassResolver implements PersisterClassResolver {
|
public class StandardPersisterClassResolver implements PersisterClassResolver {
|
||||||
|
|
||||||
public Class<? extends EntityPersister> getEntityPersisterClass(EntityBinding metadata) {
|
public Class<? extends EntityPersister> getEntityPersisterClass(EntityBinding metadata) {
|
||||||
// todo : make sure this is based on an attribute kept on the metamodel in the new code, not the concrete PersistentClass impl found!
|
|
||||||
|
|
||||||
if ( metadata.isRoot() ) {
|
if ( metadata.isRoot() ) {
|
||||||
return singleTableEntityPersister(); // EARLY RETURN!
|
return singleTableEntityPersister(); // EARLY RETURN!
|
||||||
}
|
}
|
||||||
switch ( metadata.getInheritanceType() ) {
|
switch ( metadata.getHierarchyDetails().getInheritanceType() ) {
|
||||||
case JOINED: {
|
case JOINED: {
|
||||||
return joinedSubclassEntityPersister();
|
return joinedSubclassEntityPersister();
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class PojoInstantiator implements Instantiator, Serializable {
|
||||||
public PojoInstantiator(EntityBinding entityBinding, ReflectionOptimizer.InstantiationOptimizer optimizer) {
|
public PojoInstantiator(EntityBinding entityBinding, ReflectionOptimizer.InstantiationOptimizer optimizer) {
|
||||||
this.mappedClass = entityBinding.getEntity().getClassReference();
|
this.mappedClass = entityBinding.getEntity().getClassReference();
|
||||||
this.proxyInterface = entityBinding.getProxyInterfaceType().getValue();
|
this.proxyInterface = entityBinding.getProxyInterfaceType().getValue();
|
||||||
this.embeddedIdentifier = entityBinding.getEntityIdentifier().isEmbedded();
|
this.embeddedIdentifier = entityBinding.getHierarchyDetails().getEntityIdentifier().isEmbedded();
|
||||||
this.optimizer = optimizer;
|
this.optimizer = optimizer;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class PropertyFactory {
|
||||||
*/
|
*/
|
||||||
public static IdentifierProperty buildIdentifierProperty(EntityBinding mappedEntity, IdentifierGenerator generator) {
|
public static IdentifierProperty buildIdentifierProperty(EntityBinding mappedEntity, IdentifierGenerator generator) {
|
||||||
|
|
||||||
final SimpleSingularAttributeBinding property = mappedEntity.getEntityIdentifier().getValueBinding();
|
final SimpleSingularAttributeBinding property = mappedEntity.getHierarchyDetails().getEntityIdentifier().getValueBinding();
|
||||||
|
|
||||||
// TODO: the following will cause an NPE with "virtual" IDs; how should they be set?
|
// 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.
|
// (steve) virtual attributes will still be attributes, they will simply be marked as virtual.
|
||||||
|
@ -129,8 +129,8 @@ public class PropertyFactory {
|
||||||
// this is a virtual id property...
|
// this is a virtual id property...
|
||||||
return new IdentifierProperty(
|
return new IdentifierProperty(
|
||||||
type,
|
type,
|
||||||
mappedEntity.getEntityIdentifier().isEmbedded(),
|
mappedEntity.getHierarchyDetails().getEntityIdentifier().isEmbedded(),
|
||||||
mappedEntity.getEntityIdentifier().isIdentifierMapper(),
|
mappedEntity.getHierarchyDetails().getEntityIdentifier().isIdentifierMapper(),
|
||||||
unsavedValue,
|
unsavedValue,
|
||||||
generator
|
generator
|
||||||
);
|
);
|
||||||
|
@ -140,7 +140,7 @@ public class PropertyFactory {
|
||||||
property.getAttribute().getName(),
|
property.getAttribute().getName(),
|
||||||
null,
|
null,
|
||||||
type,
|
type,
|
||||||
mappedEntity.getEntityIdentifier().isEmbedded(),
|
mappedEntity.getHierarchyDetails().getEntityIdentifier().isEmbedded(),
|
||||||
unsavedValue,
|
unsavedValue,
|
||||||
generator
|
generator
|
||||||
);
|
);
|
||||||
|
|
|
@ -241,8 +241,8 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
this.entityMetamodel = entityMetamodel;
|
this.entityMetamodel = entityMetamodel;
|
||||||
|
|
||||||
if ( !entityMetamodel.getIdentifierProperty().isVirtual() ) {
|
if ( !entityMetamodel.getIdentifierProperty().isVirtual() ) {
|
||||||
idGetter = buildPropertyGetter( mappingInfo.getEntityIdentifier().getValueBinding() );
|
idGetter = buildPropertyGetter( mappingInfo.getHierarchyDetails().getEntityIdentifier().getValueBinding() );
|
||||||
idSetter = buildPropertySetter( mappingInfo.getEntityIdentifier().getValueBinding() );
|
idSetter = buildPropertySetter( mappingInfo.getHierarchyDetails().getEntityIdentifier().getValueBinding() );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
idGetter = null;
|
idGetter = null;
|
||||||
|
@ -257,7 +257,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
boolean foundCustomAccessor = false;
|
boolean foundCustomAccessor = false;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for ( AttributeBinding property : mappingInfo.getAttributeBindingClosure() ) {
|
for ( AttributeBinding property : mappingInfo.getAttributeBindingClosure() ) {
|
||||||
if ( property == mappingInfo.getEntityIdentifier().getValueBinding() ) {
|
if ( property == mappingInfo.getHierarchyDetails().getEntityIdentifier().getValueBinding() ) {
|
||||||
continue; // ID binding processed above
|
continue; // ID binding processed above
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -387,7 +387,7 @@ public class EntityMetamodel implements Serializable {
|
||||||
|
|
||||||
// TODO: Fix after HHH-6337 is fixed; for now assume entityBinding is the root binding
|
// TODO: Fix after HHH-6337 is fixed; for now assume entityBinding is the root binding
|
||||||
//SimpleSingularAttributeBinding rootEntityIdentifier = entityBinding.getRootEntityBinding().getEntityIdentifier().getValueBinding();
|
//SimpleSingularAttributeBinding rootEntityIdentifier = entityBinding.getRootEntityBinding().getEntityIdentifier().getValueBinding();
|
||||||
SimpleSingularAttributeBinding rootEntityIdentifier = entityBinding.getEntityIdentifier().getValueBinding();
|
SimpleSingularAttributeBinding rootEntityIdentifier = entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding();
|
||||||
// entityBinding.getAttributeClosureSpan() includes the identifier binding;
|
// entityBinding.getAttributeClosureSpan() includes the identifier binding;
|
||||||
// "properties" here excludes the ID, so subtract 1 if the identifier binding is non-null
|
// "properties" here excludes the ID, so subtract 1 if the identifier binding is non-null
|
||||||
propertySpan = rootEntityIdentifier == null ?
|
propertySpan = rootEntityIdentifier == null ?
|
||||||
|
@ -428,9 +428,11 @@ public class EntityMetamodel implements Serializable {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( attributeBinding == entityBinding.getVersioningValueBinding() ) {
|
if ( attributeBinding == entityBinding.getHierarchyDetails().getVersioningAttributeBinding() ) {
|
||||||
tempVersionProperty = i;
|
tempVersionProperty = i;
|
||||||
properties[i] = PropertyFactory.buildVersionProperty( entityBinding.getVersioningValueBinding(), lazyAvailable );
|
properties[i] = PropertyFactory.buildVersionProperty(
|
||||||
|
entityBinding.getHierarchyDetails().getVersioningAttributeBinding(), lazyAvailable
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
properties[i] = PropertyFactory.buildStandardProperty( attributeBinding, lazyAvailable );
|
properties[i] = PropertyFactory.buildStandardProperty( attributeBinding, lazyAvailable );
|
||||||
|
@ -546,13 +548,13 @@ public class EntityMetamodel implements Serializable {
|
||||||
//polymorphic = ! entityBinding.isRoot() || entityBinding.hasSubclasses();
|
//polymorphic = ! entityBinding.isRoot() || entityBinding.hasSubclasses();
|
||||||
polymorphic = ! entityBinding.isRoot() || hasSubclasses;
|
polymorphic = ! entityBinding.isRoot() || hasSubclasses;
|
||||||
|
|
||||||
explicitPolymorphism = entityBinding.isExplicitPolymorphism();
|
explicitPolymorphism = entityBinding.getHierarchyDetails().isExplicitPolymorphism();
|
||||||
inherited = ! entityBinding.isRoot();
|
inherited = ! entityBinding.isRoot();
|
||||||
superclass = inherited ?
|
superclass = inherited ?
|
||||||
entityBinding.getEntity().getSuperType().getName() :
|
entityBinding.getEntity().getSuperType().getName() :
|
||||||
null;
|
null;
|
||||||
|
|
||||||
optimisticLockStyle = entityBinding.getOptimisticLockStyle();
|
optimisticLockStyle = entityBinding.getHierarchyDetails().getOptimisticLockStyle();
|
||||||
final boolean isAllOrDirty =
|
final boolean isAllOrDirty =
|
||||||
optimisticLockStyle == OptimisticLockStyle.ALL
|
optimisticLockStyle == OptimisticLockStyle.ALL
|
||||||
|| optimisticLockStyle == OptimisticLockStyle.DIRTY;
|
|| optimisticLockStyle == OptimisticLockStyle.DIRTY;
|
||||||
|
|
|
@ -323,13 +323,14 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer {
|
||||||
proxyInterfaces,
|
proxyInterfaces,
|
||||||
proxyGetIdentifierMethod,
|
proxyGetIdentifierMethod,
|
||||||
proxySetIdentifierMethod,
|
proxySetIdentifierMethod,
|
||||||
entityBinding.getEntityIdentifier().isEmbedded() ?
|
entityBinding.getHierarchyDetails().getEntityIdentifier().isEmbedded()
|
||||||
( CompositeType ) entityBinding
|
? ( CompositeType ) entityBinding
|
||||||
|
.getHierarchyDetails()
|
||||||
.getEntityIdentifier()
|
.getEntityIdentifier()
|
||||||
.getValueBinding()
|
.getValueBinding()
|
||||||
.getHibernateTypeDescriptor()
|
.getHibernateTypeDescriptor()
|
||||||
.getResolvedTypeMapping() :
|
.getResolvedTypeMapping()
|
||||||
null
|
: null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch ( HibernateException he ) {
|
catch ( HibernateException he ) {
|
||||||
|
|
|
@ -85,7 +85,7 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
||||||
assertRoot( metadata, entityBinding );
|
assertRoot( metadata, entityBinding );
|
||||||
assertIdAndSimpleProperty( entityBinding );
|
assertIdAndSimpleProperty( entityBinding );
|
||||||
|
|
||||||
assertNull( entityBinding.getVersioningValueBinding() );
|
assertNull( entityBinding.getHierarchyDetails().getVersioningAttributeBinding() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -94,8 +94,8 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
||||||
EntityBinding entityBinding = metadata.getEntityBinding( SimpleVersionedEntity.class.getName() );
|
EntityBinding entityBinding = metadata.getEntityBinding( SimpleVersionedEntity.class.getName() );
|
||||||
assertIdAndSimpleProperty( entityBinding );
|
assertIdAndSimpleProperty( entityBinding );
|
||||||
|
|
||||||
assertNotNull( entityBinding.getVersioningValueBinding() );
|
assertNotNull( entityBinding.getHierarchyDetails().getVersioningAttributeBinding() );
|
||||||
assertNotNull( entityBinding.getVersioningValueBinding().getAttribute() );
|
assertNotNull( entityBinding.getHierarchyDetails().getVersioningAttributeBinding().getAttribute() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -130,12 +130,12 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
||||||
|
|
||||||
protected void assertIdAndSimpleProperty(EntityBinding entityBinding) {
|
protected void assertIdAndSimpleProperty(EntityBinding entityBinding) {
|
||||||
assertNotNull( entityBinding );
|
assertNotNull( entityBinding );
|
||||||
assertNotNull( entityBinding.getEntityIdentifier() );
|
assertNotNull( entityBinding.getHierarchyDetails().getEntityIdentifier() );
|
||||||
assertNotNull( entityBinding.getEntityIdentifier().getValueBinding() );
|
assertNotNull( entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding() );
|
||||||
|
|
||||||
AttributeBinding idAttributeBinding = entityBinding.getAttributeBinding( "id" );
|
AttributeBinding idAttributeBinding = entityBinding.getAttributeBinding( "id" );
|
||||||
assertNotNull( idAttributeBinding );
|
assertNotNull( idAttributeBinding );
|
||||||
assertSame( idAttributeBinding, entityBinding.getEntityIdentifier().getValueBinding() );
|
assertSame( idAttributeBinding, entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding() );
|
||||||
assertSame( LongType.INSTANCE, idAttributeBinding.getHibernateTypeDescriptor().getResolvedTypeMapping() );
|
assertSame( LongType.INSTANCE, idAttributeBinding.getHibernateTypeDescriptor().getResolvedTypeMapping() );
|
||||||
|
|
||||||
assertTrue( idAttributeBinding.getAttribute().isSingular() );
|
assertTrue( idAttributeBinding.getAttribute().isSingular() );
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.sql.Types;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import org.hibernate.EntityMode;
|
||||||
import org.hibernate.internal.util.Value;
|
import org.hibernate.internal.util.Value;
|
||||||
import org.hibernate.metamodel.domain.Entity;
|
import org.hibernate.metamodel.domain.Entity;
|
||||||
import org.hibernate.metamodel.domain.SingularAttribute;
|
import org.hibernate.metamodel.domain.SingularAttribute;
|
||||||
|
@ -55,7 +56,7 @@ public class SimpleValueBindingTests extends BaseUnitTestCase {
|
||||||
public void testBasicMiddleOutBuilding() {
|
public void testBasicMiddleOutBuilding() {
|
||||||
Table table = new Table( new Schema( null, null ), "the_table" );
|
Table table = new Table( new Schema( null, null ), "the_table" );
|
||||||
Entity entity = new Entity( "TheEntity", "NoSuchClass", makeJavaType( "NoSuchClass" ), null );
|
Entity entity = new Entity( "TheEntity", "NoSuchClass", makeJavaType( "NoSuchClass" ), null );
|
||||||
EntityBinding entityBinding = new EntityBinding();
|
EntityBinding entityBinding = new EntityBinding( InheritanceType.NO_INHERITANCE, EntityMode.POJO );
|
||||||
entityBinding.setEntity( entity );
|
entityBinding.setEntity( entity );
|
||||||
entityBinding.setBaseTable( table );
|
entityBinding.setBaseTable( table );
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ public class SimpleValueBindingTests extends BaseUnitTestCase {
|
||||||
attributeBinding.getHibernateTypeDescriptor().setExplicitTypeName( "long" );
|
attributeBinding.getHibernateTypeDescriptor().setExplicitTypeName( "long" );
|
||||||
assertSame( idAttribute, attributeBinding.getAttribute() );
|
assertSame( idAttribute, attributeBinding.getAttribute() );
|
||||||
|
|
||||||
entityBinding.getEntityIdentifier().setValueBinding( attributeBinding );
|
entityBinding.getHierarchyDetails().getEntityIdentifier().setValueBinding( attributeBinding );
|
||||||
|
|
||||||
Column idColumn = table.locateOrCreateColumn( "id" );
|
Column idColumn = table.locateOrCreateColumn( "id" );
|
||||||
idColumn.setDatatype( BIGINT );
|
idColumn.setDatatype( BIGINT );
|
||||||
|
|
|
@ -50,8 +50,8 @@ public class CacheBindingTests extends BaseAnnotationBindingTestCase {
|
||||||
@Resources(annotatedClasses = HibernateCacheEntity.class, cacheMode = SharedCacheMode.ALL)
|
@Resources(annotatedClasses = HibernateCacheEntity.class, cacheMode = SharedCacheMode.ALL)
|
||||||
public void testHibernateCaching() {
|
public void testHibernateCaching() {
|
||||||
EntityBinding binding = getEntityBinding( HibernateCacheEntity.class );
|
EntityBinding binding = getEntityBinding( HibernateCacheEntity.class );
|
||||||
assertNotNull( "There should be a cache binding", binding.getCaching() );
|
assertNotNull( "There should be a cache binding", binding.getHierarchyDetails().getCaching() );
|
||||||
Caching caching = binding.getCaching();
|
Caching caching = binding.getHierarchyDetails().getCaching();
|
||||||
assertEquals( "Wrong region", "foo", caching.getRegion() );
|
assertEquals( "Wrong region", "foo", caching.getRegion() );
|
||||||
assertEquals( "Wrong strategy", AccessType.READ_WRITE, caching.getAccessType() );
|
assertEquals( "Wrong strategy", AccessType.READ_WRITE, caching.getAccessType() );
|
||||||
assertEquals( "Wrong lazy properties configuration", false, caching.isCacheLazyProperties() );
|
assertEquals( "Wrong lazy properties configuration", false, caching.isCacheLazyProperties() );
|
||||||
|
@ -61,8 +61,8 @@ public class CacheBindingTests extends BaseAnnotationBindingTestCase {
|
||||||
@Resources(annotatedClasses = JpaCacheEntity.class, cacheMode = SharedCacheMode.ALL)
|
@Resources(annotatedClasses = JpaCacheEntity.class, cacheMode = SharedCacheMode.ALL)
|
||||||
public void testJpaCaching() {
|
public void testJpaCaching() {
|
||||||
EntityBinding binding = getEntityBinding( JpaCacheEntity.class );
|
EntityBinding binding = getEntityBinding( JpaCacheEntity.class );
|
||||||
assertNotNull( "There should be a cache binding", binding.getCaching() );
|
assertNotNull( "There should be a cache binding", binding.getHierarchyDetails().getCaching() );
|
||||||
Caching caching = binding.getCaching();
|
Caching caching = binding.getHierarchyDetails().getCaching();
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Wrong region",
|
"Wrong region",
|
||||||
this.getClass().getName() + "$" + JpaCacheEntity.class.getSimpleName(),
|
this.getClass().getName() + "$" + JpaCacheEntity.class.getSimpleName(),
|
||||||
|
@ -75,7 +75,7 @@ public class CacheBindingTests extends BaseAnnotationBindingTestCase {
|
||||||
@Resources(annotatedClasses = NoCacheEntity.class, cacheMode = SharedCacheMode.NONE)
|
@Resources(annotatedClasses = NoCacheEntity.class, cacheMode = SharedCacheMode.NONE)
|
||||||
public void testNoCaching() {
|
public void testNoCaching() {
|
||||||
EntityBinding binding = getEntityBinding( NoCacheEntity.class );
|
EntityBinding binding = getEntityBinding( NoCacheEntity.class );
|
||||||
assertNull( "There should be no cache binding", binding.getCaching() );
|
assertNull( "There should be no cache binding", binding.getHierarchyDetails().getCaching() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class EmbeddedIdTests extends BaseAnnotationBindingTestCase {
|
||||||
// @Resources(annotatedClasses = { User.class, Address.class })
|
// @Resources(annotatedClasses = { User.class, Address.class })
|
||||||
public void testEmbeddable() {
|
public void testEmbeddable() {
|
||||||
EntityBinding binding = getEntityBinding( User.class );
|
EntityBinding binding = getEntityBinding( User.class );
|
||||||
EntityIdentifier identifier = binding.getEntityIdentifier();
|
EntityIdentifier identifier = binding.getHierarchyDetails().getEntityIdentifier();
|
||||||
assertTrue( identifier.isEmbedded() );
|
assertTrue( identifier.isEmbedded() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class InheritanceBindingTest extends BaseAnnotationBindingTestCase {
|
||||||
@Resources(annotatedClasses = SingleEntity.class)
|
@Resources(annotatedClasses = SingleEntity.class)
|
||||||
public void testNoInheritance() {
|
public void testNoInheritance() {
|
||||||
EntityBinding entityBinding = getEntityBinding( SingleEntity.class );
|
EntityBinding entityBinding = getEntityBinding( SingleEntity.class );
|
||||||
assertNull( entityBinding.getEntityDiscriminator() );
|
assertNull( entityBinding.getHierarchyDetails().getEntityDiscriminator() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class TableNameTest extends BaseAnnotationBindingTestCase {
|
||||||
@Resources(annotatedClasses = { A.class, B.class })
|
@Resources(annotatedClasses = { A.class, B.class })
|
||||||
public void testSingleInheritanceDefaultTableName() {
|
public void testSingleInheritanceDefaultTableName() {
|
||||||
EntityBinding binding = getEntityBinding( A.class );
|
EntityBinding binding = getEntityBinding( A.class );
|
||||||
assertEquals( "wrong inheritance type", InheritanceType.SINGLE_TABLE, binding.getInheritanceType() );
|
assertEquals( "wrong inheritance type", InheritanceType.SINGLE_TABLE, binding.getHierarchyDetails().getInheritanceType() );
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"wrong table name",
|
"wrong table name",
|
||||||
"TableNameTest$A",
|
"TableNameTest$A",
|
||||||
|
@ -64,7 +64,7 @@ public class TableNameTest extends BaseAnnotationBindingTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
binding = getEntityBinding( B.class );
|
binding = getEntityBinding( B.class );
|
||||||
assertEquals( "wrong inheritance type", InheritanceType.SINGLE_TABLE, binding.getInheritanceType() );
|
assertEquals( "wrong inheritance type", InheritanceType.SINGLE_TABLE, binding.getHierarchyDetails().getInheritanceType() );
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"wrong table name",
|
"wrong table name",
|
||||||
"TableNameTest$A",
|
"TableNameTest$A",
|
||||||
|
@ -89,7 +89,7 @@ public class TableNameTest extends BaseAnnotationBindingTestCase {
|
||||||
@Resources(annotatedClasses = { JoinedA.class, JoinedB.class })
|
@Resources(annotatedClasses = { JoinedA.class, JoinedB.class })
|
||||||
public void testJoinedSubclassDefaultTableName() {
|
public void testJoinedSubclassDefaultTableName() {
|
||||||
EntityBinding binding = getEntityBinding( JoinedA.class );
|
EntityBinding binding = getEntityBinding( JoinedA.class );
|
||||||
assertEquals( "wrong inheritance type", InheritanceType.JOINED, binding.getInheritanceType() );
|
assertEquals( "wrong inheritance type", InheritanceType.JOINED, binding.getHierarchyDetails().getInheritanceType() );
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"wrong table name",
|
"wrong table name",
|
||||||
"FOO",
|
"FOO",
|
||||||
|
@ -97,7 +97,7 @@ public class TableNameTest extends BaseAnnotationBindingTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
binding = getEntityBinding( JoinedB.class );
|
binding = getEntityBinding( JoinedB.class );
|
||||||
assertEquals( "wrong inheritance type", InheritanceType.JOINED, binding.getInheritanceType() );
|
assertEquals( "wrong inheritance type", InheritanceType.JOINED, binding.getHierarchyDetails().getInheritanceType() );
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"wrong table name",
|
"wrong table name",
|
||||||
"TableNameTest$JoinedB",
|
"TableNameTest$JoinedB",
|
||||||
|
@ -122,7 +122,7 @@ public class TableNameTest extends BaseAnnotationBindingTestCase {
|
||||||
@Resources(annotatedClasses = { TablePerClassA.class, TablePerClassB.class })
|
@Resources(annotatedClasses = { TablePerClassA.class, TablePerClassB.class })
|
||||||
public void testTablePerClassDefaultTableName() {
|
public void testTablePerClassDefaultTableName() {
|
||||||
EntityBinding binding = getEntityBinding( TablePerClassA.class );
|
EntityBinding binding = getEntityBinding( TablePerClassA.class );
|
||||||
assertEquals( "wrong inheritance type", InheritanceType.TABLE_PER_CLASS, binding.getInheritanceType() );
|
assertEquals( "wrong inheritance type", InheritanceType.TABLE_PER_CLASS, binding.getHierarchyDetails().getInheritanceType() );
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"wrong table name",
|
"wrong table name",
|
||||||
"TableNameTest$TablePerClassA",
|
"TableNameTest$TablePerClassA",
|
||||||
|
@ -130,7 +130,7 @@ public class TableNameTest extends BaseAnnotationBindingTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
binding = getEntityBinding( TablePerClassB.class );
|
binding = getEntityBinding( TablePerClassB.class );
|
||||||
assertEquals( "wrong inheritance type", InheritanceType.TABLE_PER_CLASS, binding.getInheritanceType() );
|
assertEquals( "wrong inheritance type", InheritanceType.TABLE_PER_CLASS, binding.getHierarchyDetails().getInheritanceType() );
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"wrong table name",
|
"wrong table name",
|
||||||
"TableNameTest$TablePerClassB",
|
"TableNameTest$TablePerClassB",
|
||||||
|
|
Loading…
Reference in New Issue