• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Muztaba Hasanat
Ranch Hand
Posts: 48
1
  • Mark post as helpful
  • send pies
  • 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 ? 
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic