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,JdbcDateJavaType.DateMutabilityPlan,JdbcTimeJavaType.TimeMutabilityPlan,JdbcTimestampJavaType.TimestampMutabilityPlan,JsonJavaType,MutableMutabilityPlan,NClobJavaType.NClobMutabilityPlan,SerializableJavaType.SerializableMutabilityPlan,UserTypeJavaTypeWrapper.MutabilityPlanWrapper,UserTypeMutabilityPlanAdapter,XmlJavaType
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.
- Author:
- Steve Ebersole
- See Also:
-
Method Summary
Modifier and TypeMethodDescription@Nullable Tassemble(@Nullable Serializable cached, SharedSessionContract session) Assemble a previously disassembled value.@Nullable TReturn a deep copy of the value.@Nullable Serializabledisassemble(@Nullable T value, SharedSessionContract session) Return a disassembled representation of the value.booleanCan the internal state of instances ofTbe changed?
-
Method Details
-
isMutable
boolean isMutable()Can the internal state of instances ofTbe changed?- Returns:
- True if the internal state can be changed; false otherwise.
-
deepCopy
Return a deep copy of the value.- Parameters:
value- The value to deep copy- Returns:
- The deep copy.
-