Add documentation notes about LIST semantics for mappedBy mappings
This commit is contained in:
parent
a91d23825f
commit
8183901cfe
|
@ -92,6 +92,13 @@ To maintain the order, it is necessary to explicitly use the `jakarta.persistenc
|
|||
Starting in 6.0, Hibernate allows to configure the default semantics of `List` without `@OrderColumn`
|
||||
via the `hibernate.mapping.default_list_semantics` setting.
|
||||
To switch to the more natural LIST semantics with an implicit order-column, set the setting to `LIST`.
|
||||
Beware that default LIST semantics only affects owned collection mappings.
|
||||
Unowned mappings like `@ManyToMany(mappedBy = "...")` and `@OneToMany(mappedBy = "...")` do not retain the element
|
||||
order by default, and explicitly annotating `@OrderColumn` for `@ManyToMany(mappedBy = "...")` mappings is illegal.
|
||||
|
||||
To retain the order of elements of a `@OneToMany(mappedBy = "...")` the `@OrderColumn` annotation must be applied
|
||||
explicitly. In addition to that, it is important that both sides of the relationship, the `@OneToMany(mappedBy = "...")`
|
||||
and the `@ManyToOne`, must be kept in sync. Otherwise, the element position will not be updated accordingly.
|
||||
|
||||
The default column name that stores the index is derived from the attribute name, by suffixing `_ORDER`.
|
||||
====
|
||||
|
|
Loading…
Reference in New Issue