Hibernate generates extra query
I have 2 tables A and B . I write hql like a.key=? and a.id=b.id
It generates extra query than needed.
First query is from to get elements which matches give a.key (it has 179 elements). Then it execute same query 4 times. first iteration takes 100 parame开发者_JS百科ters in 'in' clause, then 50, then 25 and then 4.
I don't understand why it can't execute query buy giving 179 elements in single query
On your relation from A to B you most probably have:
batch-size="100"
and possibly:
fetch="select"
you could change that to:
fetch="join"
or increase the batch size to 200 and see what happens.
Note that the a.id=b.id
part of your query rings a bell that your OO design and ORM mapping is not correct. You need to use relations and let hibernate do the job (in this case the joins) for you. If this is the case then the above suggestions are not applicable until you map your entities correctly.
精彩评论