HHH-6471 - Redesign how EntityBinding models hierarchy-shared information

This commit is contained in:
Steve Ebersole 2011-07-21 12:35:30 -05:00
parent 46102a2be3
commit 486352eaa9
4 changed files with 11 additions and 7 deletions

View File

@ -148,6 +148,10 @@ public class EntityBinding {
return discriminatorMatchValue;
}
public void setDiscriminatorMatchValue(String discriminatorMatchValue) {
this.discriminatorMatchValue = discriminatorMatchValue;
}
public Iterable<AttributeBinding> getAttributeBindings() {
return attributeBindingMap.values();
}

View File

@ -362,7 +362,7 @@ public class Binder {
discriminator.setValueBinding( attributeBinding );
discriminator.setInserted( discriminatorSource.isInserted() );
discriminator.setForced( discriminatorSource.isForced() );
entityBinding.setEntityDiscriminator( discriminator );
entityBinding.getHierarchyDetails().setEntityDiscriminator( discriminator );
}
private void bindDiscriminatorValue(SubclassEntitySource entitySource, EntityBinding entityBinding) {
@ -370,7 +370,7 @@ public class Binder {
if ( discriminatorValue == null ) {
return;
}
entityBinding.setDiscriminatorValue( discriminatorValue );
entityBinding.setDiscriminatorMatchValue( discriminatorValue );
}
private void bindAttributes(AttributeSourceContainer attributeSourceContainer, EntityBinding entityBinding) {

View File

@ -590,17 +590,17 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
.getValueBinding()
.getHibernateTypeDescriptor()
.getResolvedTypeMapping();
if ( entityBinding.getDiscriminatorValue() == null ) {
if ( entityBinding.getDiscriminatorMatchValue() == null ) {
discriminatorValue = NULL_DISCRIMINATOR;
discriminatorSQLValue = InFragment.NULL;
discriminatorInsertable = false;
}
else if ( entityBinding.getDiscriminatorValue().equals( NULL_STRING ) ) {
else if ( entityBinding.getDiscriminatorMatchValue().equals( NULL_STRING ) ) {
discriminatorValue = NOT_NULL_DISCRIMINATOR;
discriminatorSQLValue = InFragment.NOT_NULL;
discriminatorInsertable = false;
}
else if ( entityBinding.getDiscriminatorValue().equals( NOT_NULL_STRING ) ) {
else if ( entityBinding.getDiscriminatorMatchValue().equals( NOT_NULL_STRING ) ) {
discriminatorValue = NOT_NULL_DISCRIMINATOR;
discriminatorSQLValue = InFragment.NOT_NULL;
discriminatorInsertable = false;
@ -611,7 +611,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
! DerivedValue.class.isInstance( discrimValue );
try {
DiscriminatorType dtype = ( DiscriminatorType ) discriminatorType;
discriminatorValue = dtype.stringToObject( entityBinding.getDiscriminatorValue() );
discriminatorValue = dtype.stringToObject( entityBinding.getDiscriminatorMatchValue() );
discriminatorSQLValue = dtype.objectToSQLString( discriminatorValue, factory.getDialect() );
}
catch (ClassCastException cce) {

View File

@ -53,7 +53,7 @@ public class InheritanceBindingTest extends BaseAnnotationBindingTestCase {
@Resources(annotatedClasses = { RootOfSingleTableInheritance.class, SubclassOfSingleTableInheritance.class })
public void testDiscriminatorValue() {
EntityBinding entityBinding = getEntityBinding( SubclassOfSingleTableInheritance.class );
assertEquals( "Wrong discriminator value", "foo", entityBinding.getDiscriminatorValue() );
assertEquals( "Wrong discriminator value", "foo", entityBinding.getDiscriminatorMatchValue() );
}
@Test