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

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -