Annotation Type Immutable

  • @Target({TYPE,METHOD,FIELD})
    public @interface Immutable
    Marks an entity, collection, or attribute 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.
    • 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.