Package org.hibernate.annotations
Annotation Type Immutable
-
@Target({TYPE,METHOD,FIELD}) @Retention(RUNTIME) public @interface Immutable
Marks an entity, collection, or attribute of an entity as immutable. The absence of this annotation means the element is mutable.-
Changes made in memory to the state of an immutable entity are never synchronized to
the database. The changes are ignored, with no exception thrown. In a mapped inheritance
hierarchy,
@Immutable
may be applied only to the root entity, and is inherited by entity subclasses. To make just one entity in the hierarchy immutable, annotate its attributes individually. -
An immutable collection may not be modified. A
HibernateException
is thrown if an element is added to or removed from the collection. - An immutable attribute is ignored by the dirty-checking process, and so the persistence context does not need to keep track of its state. This may help reduce memory allocation.
-
Changes made in memory to the state of an immutable entity are never synchronized to
the database. The changes are ignored, with no exception thrown. In a mapped inheritance
hierarchy,