Interface MutabilityPlan<T>

All Superinterfaces:
Serializable
All Known Implementing Classes:
ArrayMutabilityPlan, AttributeConverterMutabilityPlanImpl, BlobJavaType.BlobMutabilityPlan, CalendarJavaType.CalendarMutabilityPlan, ClobJavaType.ClobMutabilityPlan, CompositeUserTypeJavaTypeWrapper.MutabilityPlanWrapper, DateJavaType.DateMutabilityPlan, DiscriminatedAssociationAttributeMapping.MutabilityPlanImpl, FormatMapperBasedJavaType, Immutability, ImmutableMutabilityPlan, ImmutableObjectArrayMutabilityPlan, JdbcDateJavaType.DateMutabilityPlan, JdbcTimeJavaType.TimeMutabilityPlan, JdbcTimestampJavaType.TimestampMutabilityPlan, JsonJavaType, MutableMutabilityPlan, NClobJavaType.NClobMutabilityPlan, SerializableJavaType.SerializableMutabilityPlan, UserTypeJavaTypeWrapper.MutabilityPlanWrapper, UserTypeMutabilityPlanAdapter, XmlJavaType

public interface MutabilityPlan<T> extends Serializable
Describes the mutability aspects of a given Java type.

Mutable values require special handling that is not necessary for immutable values:

  • a mutable value must be cloned when taking a "snapshot" of the state of an entity for dirty-checking, and
  • a mutable value requires more careful handling when the entity is disassembled for storage in destructured form in the second-level cache.

Neither is a requirement for correctness when dealing with an immutable object. But there might be other reasons why an immutable object requires custom implementations of disassemble(T, org.hibernate.SharedSessionContract) and assemble(java.io.Serializable, org.hibernate.SharedSessionContract).

For example:

  • if the object is not serializable, we might convert it to a serializable format,
  • if the object hold a reference to an entity, we must replace that reference with an identifier, or
  • if the object hold a reference to some heavyweight resource, we must release it.

For an immutable type, it's not usually necessary to do anything special in deepCopy(T). The method can simply return its argument.

See Also:
API Note:
The term "mutability" refers to the fact that, in general, the aspects of the Java type described by this contract are determined by whether the Java type has mutable internal state.