Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Jul 15, 2020 · 0 comments
Assignees
Labels
type: documentation A documentation update type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants