HHH-12166 : AbstractCompositionAttribute#getAttributes throws NPE for nested CompositeCustomType

This commit is contained in:
Gail Badner 2018-03-29 17:29:53 -07:00
parent 05404eff0f
commit 216ad13e6c

View File

@ -83,6 +83,11 @@ public AttributeDefinition next() {
int columnPosition = currentColumnPosition; int columnPosition = currentColumnPosition;
currentColumnPosition += type.getColumnSpan( sessionFactory() ); currentColumnPosition += type.getColumnSpan( sessionFactory() );
final CompositeType cType = getType();
final boolean nullable =
cType.getPropertyNullability() == null ||
cType.getPropertyNullability()[subAttributeNumber];
if ( type.isAssociationType() ) { if ( type.isAssociationType() ) {
// we build the association-key here because of the "goofiness" with 'currentColumnPosition' // we build the association-key here because of the "goofiness" with 'currentColumnPosition'
final AssociationKey associationKey; final AssociationKey associationKey;
@ -134,11 +139,6 @@ else if ( aType.getForeignKeyDirection() == ForeignKeyDirection.FROM_PARENT ) {
); );
} }
final CompositeType cType = getType();
final boolean nullable =
cType.getPropertyNullability() == null ||
cType.getPropertyNullability()[subAttributeNumber];
return new CompositeBasedAssociationAttribute( return new CompositeBasedAssociationAttribute(
AbstractCompositionAttribute.this, AbstractCompositionAttribute.this,
sessionFactory(), sessionFactory(),
@ -173,7 +173,7 @@ else if ( type.isComponentType() ) {
.setUpdateable( AbstractCompositionAttribute.this.isUpdateable() ) .setUpdateable( AbstractCompositionAttribute.this.isUpdateable() )
// todo : handle nested ValueGeneration strategies... // todo : handle nested ValueGeneration strategies...
// disallow if our strategy != NEVER // disallow if our strategy != NEVER
.setNullable( getType().getPropertyNullability()[subAttributeNumber] ) .setNullable( nullable )
.setDirtyCheckable( true ) .setDirtyCheckable( true )
.setVersionable( AbstractCompositionAttribute.this.isVersionable() ) .setVersionable( AbstractCompositionAttribute.this.isVersionable() )
.setCascadeStyle( getType().getCascadeStyle( subAttributeNumber ) ) .setCascadeStyle( getType().getCascadeStyle( subAttributeNumber ) )
@ -182,9 +182,6 @@ else if ( type.isComponentType() ) {
); );
} }
else { else {
final CompositeType cType = getType();
final boolean nullable = cType.getPropertyNullability() == null || cType.getPropertyNullability()[subAttributeNumber];
return new CompositeBasedBasicAttribute( return new CompositeBasedBasicAttribute(
AbstractCompositionAttribute.this, AbstractCompositionAttribute.this,
sessionFactory(), sessionFactory(),