diff --git a/hibernate-core/src/main/java/org/hibernate/tuple/component/AbstractCompositionAttribute.java b/hibernate-core/src/main/java/org/hibernate/tuple/component/AbstractCompositionAttribute.java index a20af0e7b1..953cc19f5d 100644 --- a/hibernate-core/src/main/java/org/hibernate/tuple/component/AbstractCompositionAttribute.java +++ b/hibernate-core/src/main/java/org/hibernate/tuple/component/AbstractCompositionAttribute.java @@ -83,6 +83,11 @@ public abstract class AbstractCompositionAttribute int columnPosition = currentColumnPosition; currentColumnPosition += type.getColumnSpan( sessionFactory() ); + final CompositeType cType = getType(); + final boolean nullable = + cType.getPropertyNullability() == null || + cType.getPropertyNullability()[subAttributeNumber]; + if ( type.isAssociationType() ) { // we build the association-key here because of the "goofiness" with 'currentColumnPosition' final AssociationKey associationKey; @@ -134,11 +139,6 @@ public abstract class AbstractCompositionAttribute ); } - final CompositeType cType = getType(); - final boolean nullable = - cType.getPropertyNullability() == null || - cType.getPropertyNullability()[subAttributeNumber]; - return new CompositeBasedAssociationAttribute( AbstractCompositionAttribute.this, sessionFactory(), @@ -173,7 +173,7 @@ public abstract class AbstractCompositionAttribute .setUpdateable( AbstractCompositionAttribute.this.isUpdateable() ) // todo : handle nested ValueGeneration strategies... // disallow if our strategy != NEVER - .setNullable( getType().getPropertyNullability()[subAttributeNumber] ) + .setNullable( nullable ) .setDirtyCheckable( true ) .setVersionable( AbstractCompositionAttribute.this.isVersionable() ) .setCascadeStyle( getType().getCascadeStyle( subAttributeNumber ) ) @@ -182,9 +182,6 @@ public abstract class AbstractCompositionAttribute ); } else { - final CompositeType cType = getType(); - final boolean nullable = cType.getPropertyNullability() == null || cType.getPropertyNullability()[subAttributeNumber]; - return new CompositeBasedBasicAttribute( AbstractCompositionAttribute.this, sessionFactory(),