[ https://issues.apache.org/jira/browse/CAY-2738?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Nikita Timofeev updated CAY-2738: --------------------------------- Fix Version/s: 5.0-M2 (was: 5.0-M1) > Mapping Proposal: Directonless DbRelationship > --------------------------------------------- > > Key: CAY-2738 > URL: https://issues.apache.org/jira/browse/CAY-2738 > Project: Cayenne > Issue Type: Improvement > Reporter: Andrus Adamchik > Priority: Major > Fix For: 5.0-M2 > > > _It remains to be seen whether the proposed API gives us more efficient and > easy-to-use data structure. More experimentation is needed._ > A pair of DbRelationships between two tables is really a single set of joins, > not two independent relationships. We should represent it in Cayenne as such. > E.g. [*]: > {noformat} > public class DbRelationshipSide { > DbEntity entity; > String name; > // complementary "other" side > DbRelationshipSide otherSide; > // list of columns that matches the order on the complementary "other" > side > List<String> joinColumns; > boolean toMany; > } > public class DbRelationship { > Map<String, DbRelationshipSide> sides; > public DbRelationshipSide getSide(String dbEntityName) { > DbRelationshipSide side = sides.get(dbEntityName); > return Objects.requireNonNull(side, > () -> "Entity " + dbEntityName + " is not a part of the > relationship"); > } > } > {noformat} > A single DbRelationship will be linked to both DbEntities, and we won't need > to manage two identical sets of joins. From the perspective of an entity, the > relationship becomes directed, by accessing its side that matches the entity > name. > [*] I am omitting "toDepPk" property in the example. Per CAY-2739 it may be > renamed to "fk". -- This message was sent by Atlassian Jira (v8.20.10#820010)