orm - How to make an optimal hibernate query with three objects? -
i have query don't know how make optimal. have 3 objects.
- scp
- question : has field points scp (scp_id)
- answer : has field points question (question_id)
how can make query counts number of answer within given scp
what this:
select count(a) answer a.question.scp.id = :id
which generates following sql:
select count(answer0_.id) col_0_0_ answer answer0_, question question1_ answer0_.question_id=question1_.id , question1_.scp_id=?
seems pretty efficient.
Comments
Post a Comment