GeeCON Prague 2014*
The moose likes Object Relational Mapping and the fly likes OPEN JPA - OneToMany uniderictional with multiple columns Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "OPEN JPA - OneToMany uniderictional with multiple columns" Watch "OPEN JPA - OneToMany uniderictional with multiple columns" New topic
Author

OPEN JPA - OneToMany uniderictional with multiple columns

vasu muli
Greenhorn

Joined: May 11, 2012
Posts: 3
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OPEN JPA - OneToMany uniderictional with multiple columns