Uploaded image for project: 'Spring Data JDBC'
  1. Spring Data JDBC
  2. DATAJDBC-577

Documentation: one-to-many relationship via Set customizable with @MappedCollection

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.1 M1 (2020.0.0)
    • Fix Version/s: None
    • Component/s: Documentation
    • Labels:
      None

      Description

      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.

        Attachments

          Activity

            People

            Assignee:
            schauder Jens Schauder
            Reporter:
            cleemansen Clemens Hahn
            Last updater:
            Oliver Drotbohm
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: