HHH-6970 - Expand notion of "natural id mutability" to ternary value
This commit is contained in:
parent
73dec965a0
commit
e0a09dbd79
|
@ -284,12 +284,10 @@ public class PropertyBinder {
|
|||
prop.setGeneration( PropertyGeneration.parse( generated.toString().toLowerCase() ) );
|
||||
}
|
||||
}
|
||||
NaturalId naturalId = property != null ?
|
||||
property.getAnnotation( NaturalId.class ) :
|
||||
null;
|
||||
NaturalId naturalId = property != null ? property.getAnnotation( NaturalId.class ) : null;
|
||||
if ( naturalId != null ) {
|
||||
NaturalIdMutability mutability = naturalId.mutability();
|
||||
if ( mutability == null ) {
|
||||
if ( mutability == NaturalIdMutability.UNSPECIFIED ) {
|
||||
mutability = naturalId.mutable()
|
||||
? NaturalIdMutability.MUTABLE
|
||||
: NaturalIdMutability.IMMUTABLE_CHECKED;
|
||||
|
|
|
@ -150,10 +150,12 @@ public class Property implements Serializable, MetaAttributable {
|
|||
// if the property mapping consists of all formulas,
|
||||
// make it non-updateable
|
||||
final boolean[] columnUpdateability = value.getColumnUpdateability();
|
||||
return updateable && (
|
||||
//columnUpdateability.length==0 ||
|
||||
!ArrayHelper.isAllFalse(columnUpdateability)
|
||||
);
|
||||
final boolean isImmutableNaturalId = isNaturalIdentifier()
|
||||
&& ( NaturalIdMutability.IMMUTABLE.equals( getNaturalIdMutability() )
|
||||
|| NaturalIdMutability.IMMUTABLE_CHECKED.equals( getNaturalIdMutability() ) );
|
||||
return updateable
|
||||
&& !isImmutableNaturalId
|
||||
&& !ArrayHelper.isAllFalse(columnUpdateability);
|
||||
}
|
||||
|
||||
public boolean isInsertable() {
|
||||
|
@ -174,7 +176,8 @@ public class Property implements Serializable, MetaAttributable {
|
|||
this.generation = generation;
|
||||
}
|
||||
|
||||
public void setUpdateable(boolean mutable) {
|
||||
public void setUpdateable(
|
||||
boolean mutable) {
|
||||
this.updateable = mutable;
|
||||
}
|
||||
|
||||
|
@ -324,4 +327,5 @@ public class Property implements Serializable, MetaAttributable {
|
|||
public void setNaturalIdMutability(NaturalIdMutability naturalIdMutability) {
|
||||
this.naturalIdMutability = naturalIdMutability;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.jboss.logging.Logger;
|
|||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.NaturalIdMutability;
|
||||
import org.hibernate.engine.OptimisticLockStyle;
|
||||
import org.hibernate.engine.internal.Versioning;
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
|
@ -154,7 +155,7 @@ public class EntityMetamodel implements Serializable {
|
|||
|
||||
propertySpan = persistentClass.getPropertyClosureSpan();
|
||||
properties = new StandardProperty[propertySpan];
|
||||
List naturalIdNumbers = new ArrayList();
|
||||
List<Integer> naturalIdNumbers = new ArrayList<Integer>();
|
||||
// temporary ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
propertyNames = new String[propertySpan];
|
||||
propertyTypes = new Type[propertySpan];
|
||||
|
@ -195,7 +196,7 @@ public class EntityMetamodel implements Serializable {
|
|||
|
||||
if ( prop.isNaturalIdentifier() ) {
|
||||
naturalIdNumbers.add( i );
|
||||
if ( prop.isUpdateable() ) {
|
||||
if ( prop.isUpdateable() && NaturalIdMutability.MUTABLE.equals( prop.getNaturalIdMutability() ) ) {
|
||||
foundUpdateableNaturalIdProperty = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue