You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Andrus Adamchik (Jira)" <ji...@apache.org> on 2022/07/03 10:19:00 UTC
[jira] [Created] (CAY-2738) Mapping Proposal: Directonless DbRelationship
Andrus Adamchik created CAY-2738:
------------------------------------
Summary: Mapping Proposal: Directonless DbRelationship
Key: CAY-2738
URL: https://issues.apache.org/jira/browse/CAY-2738
Project: Cayenne
Issue Type: Improvement
Reporter: Andrus Adamchik
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.
_It remains to be seen if the new API gives us more efficient and easy-to-use data structure. More experimentation is needed._
[*] I am omitting "toDepPk" property in the example. Will discuss improving that separately.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)