HHH-6547 : Basic properties cannot be made nullable in HBM XML

This commit is contained in:
Gail Badner 2011-08-04 18:58:10 -07:00
parent cb5a74fd51
commit 6065d57e39
2 changed files with 10 additions and 4 deletions

View File

@ -987,12 +987,16 @@ public class Binder {
.getNamingStrategy()
.propertyToColumnName( attributeBinding.getAttribute().getName() );
name = quoteIdentifier( name );
valueBindings.add(
new SimpleValueBinding(
attributeBinding.getContainer()
Column column = attributeBinding.getContainer()
.seekEntityBinding()
.getPrimaryTable()
.locateOrCreateColumn( name )
.locateOrCreateColumn( name );
column.setNullable( relationalValueSourceContainer.areValuesNullableByDefault() );
valueBindings.add(
new SimpleValueBinding(
column,
relationalValueSourceContainer.areValuesIncludedInInsertByDefault(),
relationalValueSourceContainer.areValuesIncludedInUpdateByDefault()
)
);
}

View File

@ -166,6 +166,7 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
assertTrue( idAttributeBinding.getAttribute().isSingular() );
assertNotNull( idAttributeBinding.getAttribute() );
SingularAttributeBinding singularIdAttributeBinding = (SingularAttributeBinding) idAttributeBinding;
assertFalse( singularIdAttributeBinding.isNullable() );
SingularAttribute singularIdAttribute = ( SingularAttribute ) idAttributeBinding.getAttribute();
BasicType basicIdAttributeType = ( BasicType ) singularIdAttribute.getSingularAttributeType();
assertSame( Long.class, basicIdAttributeType.getClassReference() );
@ -182,6 +183,7 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
assertTrue( entityBinding.locateAttributeBinding( "name" ).getAttribute().isSingular() );
SingularAttributeBinding nameBinding = (SingularAttributeBinding) entityBinding.locateAttributeBinding( "name" );
assertTrue( nameBinding.isNullable() );
assertSame( StringType.INSTANCE, nameBinding.getHibernateTypeDescriptor().getResolvedTypeMapping() );
assertNotNull( nameBinding.getAttribute() );
assertNotNull( nameBinding.getValue() );