Skip to content

Commit 28d40b0

Browse files
committed
Improve documentation for mapping sets.
The documentation now correctly states that the back reference name can by customized via annotation. Closes #797
1 parent 3c7cbcf commit 28d40b0

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/main/antora/modules/ROOT/pages/jdbc/mapping.adoc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,22 @@ The properties of the following types are currently supported:
5555
* References to other entities.
5656
They are considered a one-to-one relationship, or an embedded type.
5757
It is optional for one-to-one relationship entities to have an `id` attribute.
58-
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].
58+
The table of the referenced entity is expected to have an additional column with a name based on the referencing entity see <<jdbc.entity-persistence.types.backrefs>>.
5959
Embedded entities do not need an `id`.
60-
If one is present it gets ignored.
60+
If one is present it gets mapped as a normal attribute without any special meaning.
6161

6262
* `Set<some entity>` is considered a one-to-many relationship.
63-
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].
63+
The table of the referenced entity is expected to have an additional column with a name based on the referencing entity see <<jdbc.entity-persistence.types.backrefs>>.
6464

6565
* `Map<simple type, some entity>` is considered a qualified one-to-many relationship.
66-
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.
67-
You can change this behavior by implementing `NamingStrategy.getReverseColumnName(PersistentPropertyPathExtension path)` and `NamingStrategy.getKeyColumn(RelationalPersistentProperty property)`, respectively.
68-
Alternatively you may annotate the attribute with `@MappedCollection(idColumn="your_column_name", keyColumn="your_key_column_name")`
66+
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 <<jdbc.entity-persistence.types.backrefs>>) and one with the same name and an additional `_key` suffix for the map key.
67+
68+
* `List<some entity>` is mapped as a `Map<Integer, some entity>`. The same additional columns are expected and the names used can be customized in the same way.
69+
70+
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.
71+
Alternatively you may annotate the attribute with `@MappedCollection(idColumn="your_column_name", keyColumn="your_key_column_name")`.
72+
Specifying a key column for a `Set` has no effect.
6973

70-
* `List<some entity>` is mapped as a `Map<Integer, some entity>`.
7174

7275
[[mapping.usage.annotations]]
7376
=== Mapping Annotation Overview

0 commit comments

Comments
 (0)