• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Joining two tables using hibernate

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!!!

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

regards,
PP.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic