DATAJDBC-520 - Improved documentation for MappedCollection annotation.
Original pull request: #206.
This commit is contained in:
committed by
Jens Schauder
parent
eb9e346c66
commit
32f997ebd9
@@ -22,9 +22,10 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* The annotation to configure the mapping for a {@link List} or {@link Map} property in the database.
|
||||
* The annotation to configure the mapping for a {@link List}, {@link Set} or {@link Map} property in the database.
|
||||
*
|
||||
* @since 1.1
|
||||
* @author Bastian Wilhelm
|
||||
|
||||
@@ -271,10 +271,9 @@ public class MyEntity {
|
||||
----
|
||||
====
|
||||
|
||||
The {javadoc-base}org/springframework/data/relational/core/mapping/MappedCollection.html[`@MappedCollection`] annotation can be used on a reference type (one-to-one relationship) or on Sets, Lists, and Maps (one-to-many relationship)
|
||||
On all these types the `value` element of the annotation is used to provide a custom name for the foreign key column referencing the id column in the other table.
|
||||
In the following example the corresponding table for the `MySubEntity` class has a name column, and the id column of the `MyEntity` id for relationship reasons.
|
||||
The name of this `MySubEntity` class's id column can also be customized with the `idColumn` element of the {javadoc-base}org/springframework/data/relational/core/mapping/MappedCollection.html[`@MappedCollection`] annotation:
|
||||
The {javadoc-base}org/springframework/data/relational/core/mapping/MappedCollection.html[`@MappedCollection`] annotation can be used on Sets, Lists, and Maps.
|
||||
`idColumn` element of the annotation provides a custom name for the foreign key column referencing the id column in the other table.
|
||||
In the following example the corresponding table for the `MySubEntity` class has a `NAME` column, and the `CUSTOM_MY_ENTITY_ID_COLUMN_NAME` column of the `MyEntity` id for relationship reasons:
|
||||
|
||||
====
|
||||
[source, java]
|
||||
@@ -283,8 +282,8 @@ public class MyEntity {
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@MappedCollection(idColumn = "CUSTOM_COLUMN_NAME")
|
||||
Set<MySubEntity> name;
|
||||
@MappedCollection(idColumn = "CUSTOM_MY_ENTITY_ID_COLUMN_NAME")
|
||||
Set<MySubEntity> subEntities;
|
||||
}
|
||||
|
||||
public class MySubEntity {
|
||||
|
||||
Reference in New Issue
Block a user