Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
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. [*]:
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"); } }
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".
Attachments
Issue Links
- supercedes
-
CAY-2554 Redesign dbRelationship's and join's structure
- Open