Skip to content

Documentation: one-to-many relationship via Set customizable with @MappedCollection [DATAJDBC-577] #797

Closed
@spring-projects-issues

Description

@spring-projects-issues

Clemens Hahn opened DATAJDBC-577 and commented

The documentation says:

  • Set<some entity> is considered a one-to-many relationship. The table of the referenced entity is expected to have an additional column named the same as the table of the referencing entity. You can change this name by implementing NamingStrategy.getReverseColumnName(PersistentPropertyPathExtension path).

  • Map<simple type, some entity> is considered a qualified one-to-many relationship. The table of the referenced entity is expected to have two additional columns: One named the same as the table of the referencing entity for the foreign key 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 second option (referencing entities via a Map) mentions the possibility to customize it with @MappedCollection; the first one (via a Set) not.

I tried the same customization using a Set with @MappedCollection and it works. So I think this is also a valid possibility for the set-option? If so please mention the @MappedCollection-Option in the Set-case


Affects: 2.1 M1 (2020.0.0)

Reference URL: https://docs.spring.io/spring-data/jdbc/docs/2.1.0-M1/reference/html/#jdbc.entity-persistence.types

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions