From 28d40b017afe91c1481fa9bd64769cae4d4eec36 Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Fri, 13 Oct 2023 15:02:55 +0200 Subject: [PATCH] Improve documentation for mapping sets. The documentation now correctly states that the back reference name can by customized via annotation. Closes #797 --- .../antora/modules/ROOT/pages/jdbc/mapping.adoc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/antora/modules/ROOT/pages/jdbc/mapping.adoc b/src/main/antora/modules/ROOT/pages/jdbc/mapping.adoc index 43100036d..62ecf2991 100644 --- a/src/main/antora/modules/ROOT/pages/jdbc/mapping.adoc +++ b/src/main/antora/modules/ROOT/pages/jdbc/mapping.adoc @@ -55,19 +55,22 @@ The properties of the following types are currently supported: * References to other entities. They are considered a one-to-one relationship, or an embedded type. It is optional for one-to-one relationship entities to have an `id` attribute. -The table of the referenced entity is expected to have an additional column with a name based on the referencing entity see xref:jdbc/entity-persistence.adoc#jdbc.entity-persistence.types.backrefs[Back References]. +The table of the referenced entity is expected to have an additional column with a name based on the referencing entity see <>. Embedded entities do not need an `id`. -If one is present it gets ignored. +If one is present it gets mapped as a normal attribute without any special meaning. * `Set` is considered a one-to-many relationship. -The table of the referenced entity is expected to have an additional column with a name based on the referencing entity see xref:jdbc/entity-persistence.adoc#jdbc.entity-persistence.types.backrefs[Back References]. +The table of the referenced entity is expected to have an additional column with a name based on the referencing entity see <>. * `Map` is considered a qualified one-to-many relationship. -The table of the referenced entity is expected to have two additional columns: One named based on the referencing entity for the foreign key (see xref:jdbc/entity-persistence.adoc#jdbc.entity-persistence.types.backrefs[Back References]) and one with the same name and an additional `_key` suffix for the map key. -You can change this behavior by implementing `NamingStrategy.getReverseColumnName(PersistentPropertyPathExtension path)` and `NamingStrategy.getKeyColumn(RelationalPersistentProperty property)`, respectively. -Alternatively you may annotate the attribute with `@MappedCollection(idColumn="your_column_name", keyColumn="your_key_column_name")` +The table of the referenced entity is expected to have two additional columns: One named based on the referencing entity for the foreign key (see <>) and one with the same name and an additional `_key` suffix for the map key. + +* `List` is mapped as a `Map`. The same additional columns are expected and the names used can be customized in the same way. + +For `List`, `Set`, and `Map` naming of the back reference can be controlled by implementing `NamingStrategy.getReverseColumnName(PersistentPropertyPathExtension path)` and `NamingStrategy.getKeyColumn(RelationalPersistentProperty property)`, respectively. +Alternatively you may annotate the attribute with `@MappedCollection(idColumn="your_column_name", keyColumn="your_key_column_name")`. +Specifying a key column for a `Set` has no effect. -* `List` is mapped as a `Map`. [[mapping.usage.annotations]] === Mapping Annotation Overview