Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OPEN JPA - OneToMany uniderictional with multiple columns

 
vasu muli
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the Requirement, have 2 tables Log & Client .


LOG
----------------
ClaimNo DataTime CUSTOMER_ID CLIENT_ID CLIENT_GROUP_ID
Claim1 2012-12-30 cust1 cleint1 grp1
Claim2 2012-09-20 cust1 cleint1 grp1
Claim3 2012-09-20 cust2 cleint2 grp2


Client
-----------------
CustomerID ClientID Client_Group_ID MemberID familyID
cust1 cleint1 grp1 mem1 fam1
cust1 cleint1 grp1 mem2 fam2
cust1 cleint1 grp1 mem3 fam3
cust2 cleint2 grp2 mem1 fam1
cust2 cleint2 grp3 mem2 fam2


Class Log{
String ClaimNo ;
Date DateTime;

@OneToMany(mappedBy = "log_Client", targetEntity = Client.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private List<Cleint> cleintList;

}

Class Client{

String Customer_ID;
String Client_ID;
String Client_Group_ID;
String MemberID;
String FamilyID;

@ManyToOne
@JoinColumns( {
@JoinColumn(name = "CUSTOMER_ID", referencedColumnName = "CUSTOMER_ID"),
@JoinColumn(name = "CLIENT_ID", referencedColumnName = "CLIENT_ID"),
@JoinColumn(name = "CLIENT_GROUP_ID", referencedColumnName = "CLIENT_GROUP_ID") })
private Log log_Client;
}

If input is ClaimNo = "Claim1" & DateTime = "2012-12-30" .

Expected Output is

ClaimNo DataTime CUSTOMER_ID CLIENT_ID CLIENT_GROUP_ID
Claim1 2012-12-30 cust1 cleint1 grp1

CustomerID ClientID Client_Group_ID MemberID FamilyID
cust1 cleint1 grp1 mem1 fam1
cust1 cleint1 grp1 mem2 fam2
cust1 cleint1 grp1 mem3 fam3


But it is giving as shown below

ClaimNo DataTime CUSTOMER_ID CLIENT_ID CLIENT_GROUP_ID
Claim1 2012-12-30 cust1 cleint1 grp1
Claim1 2012-09-20 cust1 cleint1 grp1


CustomerID ClientID Client_Group_ID MemberID FamilyID
cust1 cleint1 grp1 mem1 fam1
cust1 cleint1 grp1 mem2 fam2
cust1 cleint1 grp1 mem3 fam3
ClaimNo DataTime CUSTOMER_ID CLIENT_ID CLIENT_GROUP_ID
Claim2 2012-09-20 cust1 cleint1 grp1


The Birectional is getting different result and going in loop.

Thanks a lot for the Help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic