Hibenate create criteria for Joins on Secondary keys

37 Views Asked by At

Is it possible to do something like this with hibernate criteria.

select * from A inner join
B on A.customer_id = B.id left outer join
C on A.customer_id = C.customer_id;

Table A and C have a attribute customer_id, Table B primary key is id which is customer_id in table A and table C.

I want to join the result of table A and table B with table C on A.customer_id and C.customer_id.

I tried doing this:

Criteria criteria = session.createCriteria(A.class, "A_");

criteria.createCriteria(A_.invoiceId, INNER_JOIN);

// Now join table C with A.invoice_id = C.invoice_id

Now how to join C?

I am blocked after this as createCriteria doesn't ask for parameters on which join should be applied.

0

There are 0 best solutions below