Use @Mutable
on a @Basic
mapping to specify if the value of a complex field type can be changed (or not changed) instead of being replaced. Mutable mappings may affect the performance of change tracking; attribute change tracking can only be weaved with non-mutable mappings.
Annotation Elements
Table 2-33 describes this annotation's elements.
Table 2-33 @Mutable Annotation Elements
Annotation Element | Description | Default |
---|---|---|
|
(Optional) Specify if the mapping is mutable. |
true |
Usage
Most basic types (such as int
, long
, float
, double
, String
, and BigDecimal
) are not mutable.
By default, Date
and Calendar
types are assumed to be not mutable. To make these types mutable, use the @Mutable
annotation. You can also use the global persistence property eclipselink.temporal.mutable
to set the mappings as mutable.
By default, serialized types are assumed to be mutable. You can set the @Mutable
annotation to false
to make these types not mutable.
You can also configure mutable mappings for Date
and Calendar
fields in the persistence unit in the persistence.xml
file.
Examples
Example 2-65 shows how to use the @Mutable
annotation to specify Employee
field hireDate
.
Example 2-65 Using @Mutable Annotation
@Entity public class Employee implements Serializable { ... @Temporal(DATE) @Mutable public Calendar getHireDate() { return hireDate; } .. }
Example 2-66 shows how to configure mutable mappings in the persistence unit persistence.xml
file or by importing a property
map.
Example 2-66 Specifying Mutable Mappings in persistence.xml
Using persistence.xml
file:
<property name="eclipselink.temporal.mutable" value="true"/>
Using property
map:
import org.eclipse.persistence.config.PersistenceUnitProperties; propertiesMap.put(PersistenceUnitProperties.TEMPORAL_MUTABLE, "false");
See Also
For more information, see: