Package com.blazebit.persistence.view
Annotation Type UpdatableMapping
@Target(METHOD) @Retention(RUNTIME) public @interface UpdatableMapping
Specifies the update handling of values assigned to the annotated attribute.
- Since:
- 1.1.0
- Author:
- Christian Beikov
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description CascadeType[]
cascade
The actions that should cascade for the runtime type of objects assigned to the annotated attribute.boolean
orphanRemoval
Specifies whether an element should be deleted when it is removed/replaced in the attribute value.Class<?>[]
persistSubtypes
Subtypes of the attribute element type that are allowed to receiveCascadeType.PERSIST
cascade events.Class<?>[]
subtypes
Subtypes of the attribute element type that are allowed to be receiveCascadeType.PERSIST
andCascadeType.UPDATE
cascade events.boolean
updatable
Specifies whether the relation for the attribute is updatable.Class<?>[]
updateSubtypes
Subtypes of the attribute element type that are allowed to receiveCascadeType.UPDATE
cascade events.
-
Element Details
-
updatable
boolean updatableSpecifies whether the relation for the attribute is updatable. If the attribute maps a *ToOne relation and updatable() isfalse
, the relation isn't updated and the referenced entity unless overridden by cascade() isn't updated either. If it is set totrue
, at least the relation updated. If the attribute maps a *ToMany relation and updatable() isfalse
, changes to the collection aren't applied to the collection of the backing entity. If it is set totrue
, at least the collection changes are applied. Unless overridden by this attribute, every attribute that also has a setter is updatable.- Returns:
- Whether attribute updates are enabled
- Default:
- true
-
orphanRemoval
boolean orphanRemovalSpecifies whether an element should be deleted when it is removed/replaced in the attribute value. If the backing entity of the updatable entity view defines orphan removal, this setting must be set to true, otherwise it is a configuration error. The rationale behind this, is that it should be apparent by looking at the attribute definition that orphan removal happens. If this weren't a configuration error, the #FlushStrategy.ENTITY
flush strategy would behave differently than other strategies, as the JPA provider would do the orphan removal in case of an update whereas other strategies would adhere to the orphan removal defined on this attribute.- Returns:
- Whether removed/replaced elements on the attribute should be deleted
- Default:
- false
-
cascade
CascadeType[] cascadeThe actions that should cascade for the runtime type of objects assigned to the annotated attribute. Allows to override the default cascading strategy for a method attribute.The default strategy
CascadeType.AUTO
causes that attributes that are mutable to cascade all changes. Updatable and non-updatable attributes that have a non-mutable/immutable type do not cascade changes by default.An updatable attribute with a non-mutable type can define cascading so that objects of a subtype are persisted or updated. A mutable attribute can be excluded from persisting or updating by annotating an empty array of cascade types.
- Returns:
- The events that should further cascade
- Since:
- 1.2.0
- Default:
- {AUTO}
-
subtypes
Class<?>[] subtypesSubtypes of the attribute element type that are allowed to be receiveCascadeType.PERSIST
andCascadeType.UPDATE
cascade events.- Returns:
- Allowed subtypes for cascading
- Since:
- 1.2.0
- Default:
- {}
-
persistSubtypes
Class<?>[] persistSubtypesSubtypes of the attribute element type that are allowed to receiveCascadeType.PERSIST
cascade events.- Returns:
- Allowed subtypes for persist cascading
- Since:
- 1.2.0
- Default:
- {}
-
updateSubtypes
Class<?>[] updateSubtypesSubtypes of the attribute element type that are allowed to receiveCascadeType.UPDATE
cascade events.- Returns:
- Allowed subtypes for update cascading
- Since:
- 1.2.0
- Default:
- {}
-