Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Joining two tables using hibernate

 
prash patil
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I got one problem in joing 2 tables.

The problem is as follows.
I do have to tables CAMPAIGNREQUEST (ID,CLIENTID,EXTERNALID,ERRORCODE,CREATED)
and CLIENT (ID,NAME,PRIORITY,GENESISBILLERID,CREATED)

For Retrieving the "GENESISBILLERID" from CLEINT I have writtent 2 DB calls.
One is to Retrieve the CleintID from CAMPAIGNREQUEST As initially I have ID of CAMPAIGNREQUEST
Then I used the CleintID from the Result and then Fired another DB Call to Get CLIENT Object (i.e GENESISBILLERID )

I feel this is an Ugly way to have two seperate call to retrieve GENESISBILLERID from CLIENT.

Can any one plese suggest how I Can define relation ship between these two tables? (CLIENT 1-----M CAMPAIGNREQUEST )
So that in one DB call I can get the required Result.

I dont want to use HQL in proj. I have on HibernateUtil class which dones all DB related operation and i have used Criteria So far for all my Queries..


Thanks,
PP.
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try create a similar mapping in CAMPAIGNREQUEST.hbm.xml




So when you load the CampaignRequest Object you should get the Collection of Client Objects which you can traverse to get the required Property.

Hope this helps.
 
prash patil
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!!!

But how i am going to define Criteria to get the GENESISBILLERID of CLIENT...

regards,
PP.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic