Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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

Hibernate : many to many mapping and inner join query results.

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I have 2 two tables(css_job and css_candidate) with many to many mapping. it is normalized and many to many mappings are put in table called css_candidatejob.

I have to show all the candidates and jobs provided that there is mapping between these two in css_candidatejob.
query is "select c.firstName ,j.title from css_job j inner join css_candidate c"

i am trying to achieve this using hibernate mappings and HQL.

here is my candidate mapping.


here is job mapping.


java beans(Job and Candidate) have private String attributes with the same name and sets with candidates and jobs as names.

here is the code that fires inner join between these two tables.


now my questions is how to show firstName from this result. for timebeing i am trying to print first name for tiem being but need fields from both job and candidate. so i can not specifically say select candidate in query and assign it to candidate Class.

Please suggest. it could be something very simple as i have started working with hibernate very recently.
thanks
 
vani venkat
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry here is the query that is returning expected results. how should i map in hibernate.

select c.firstName,c.lastName,j.jobTitle,cj.status from css_candidate c,css_candidatejob cj,css_job j where c.candidateSeq = cj.candidateSeq and cj.jobSeq = j.jobSeq



should i have separate mapping file and java bean persistent class for css_candidatejob? and do "from candidateJob". this will return all records in candidateJob table as a list of candidateJob beans. Now how to load candidate and job classes for each of the rows to get firstName and jobTitle?

really appreciate help in this.
 
If you're gonna buy things, buy this thing and I get a fat kickback:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic