Skip to content
Advertisement

How to join 3 table using hibernate criteria?

I have three tables.

  1. parent
  2. parent_child_mapping
  3. child

I want to join the 3 tables & filter by child name using ‘CriteriaBuilder’ & ‘Predicate’. How can i implement the below sql query using ‘CriteriaBuilder’ & ‘Predicate’.

JavaScript

Parent entity

JavaScript

Parent child mapping entity

JavaScript

Child entity

JavaScript

Advertisement

Answer

You just create a root for every entity and add the condition to the where clause. Something like this:

JavaScript
Advertisement