Interface MutabilityPlan<T>
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
ArrayMutabilityPlan, BlobJavaType.BlobMutabilityPlan, CalendarJavaType.CalendarMutabilityPlan, ClobJavaType.ClobMutabilityPlan, DateJavaType.DateMutabilityPlan, FormatMapperBasedJavaType, Immutability, ImmutableMutabilityPlan, ImmutableObjectArrayMutabilityPlan, JdbcDateJavaType.DateMutabilityPlan, JdbcTimeJavaType.TimeMutabilityPlan, JdbcTimestampJavaType.TimestampMutabilityPlan, JsonJavaType, MutableMutabilityPlan, NClobJavaType.NClobMutabilityPlan, SerializableJavaType.SerializableMutabilityPlan, 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, SharedSessionContract) and assemble(Serializable, 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.
-
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
-