• 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

How to join Multiple table using hibernate criteria where entity relationship is not direct ?

 
Ranch Hand
Posts: 50
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have three entity. those are -




In these three entity I would like to perform following sql-

In this case `Account` entity has no relation with the `Organization` entity directly. `Account` entity has the relation via `Book`. How can I achieve this using hibernate criteria dynamic query ?  
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Muztaba Hasanat wrote:In this case `Account` entity has no relation with the `Organization` entity directly. `Account` entity has the relation via `Book`. How can I achieve this using hibernate criteria dynamic query ?  


You need to create seperate Join objects for each of the required joins, then you can create the needed conditions and finally create your query. This is how you can create the required Join objectsNow you have the different Join objects and you can add the necessary conditionsAnd finally you can create the query using these building blocks.

Hope it helps!
Kind regards,
Roel
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But it fires multiple queries which is not fetching the exact data from the child table
 
reply
    Bookmark Topic Watch Topic
  • New Topic