多对一单向和双向关系的 JPQL 查询
class ParentEntity{
@Id
String parentId1; //composite key
@Id
String parentId2;
@ManyToOne
ChildEntity childEntityRef;
}
class ChildEntity { //ManyToOne Unidirectional Relationship case
@Id
String childId1; //composite key
@Id
String childId2;
}
or
class ChildEntity { //ManyToOne Bidirectional Relationship case
@Id
String childId1; //composite key
@Id
String childId2;
@OneToMany
List<ParentEntity> parentEntitiesref;
}
_______________________________________________________________________
|| ParentEntity Table || ChildEntity Table ||
||_________________________________________||__________________________||
parentId1|parentId2|childId1_FK|childId1_FK|| childId1| childId2 ||
||_______|_________|___________|___________||_________|________________||
|| p11 |p21 | c11 |c21 || c11 | c21 ||
|| p12 |p22 | c11 |c21 || c12 | c22 ||
|| p13 |p23 | c12 |c22 || c13 | c23 ||
|| p14 |p24 | c12 |c22 || | ||
||_______|_________|___________|___________||_________|________________||
我需要 JPQL 查询来访问未连接到特定 ParentEntity 的所有 childEntity 的列表(在这两种情况下都是单向和双向关系)。
Example -
For ParentEntity[p11,p21] get All other disconnected List of ChildEntity([c12,c22],[c13,c23])
最好的问候,
Gaurav Gupta。