java - Hibernate (with Grails 2.3.5) - batch load entities -


I have some organizations defined like this:

  class A {string name list & Lt; B & gt; ; List is constant hamney = [list: b]} class B {String name} class C {A a1; A2;} class D {A3; C;}  

See the C and D unit A and the same A can be used by C and D.

When using HQL, I do this, get a list of D as well as bring the C object:

  list & lt; D & gt; List = D.executeQuery ('de _d fetch join _d.c _c')  

Now, when I list [0]. A3 , then it loads a unit if I reach list [0] .c.a1 , then it also loads a unit.

This generates two requests:

 choose  from A where AID =? // List access to [0]. Select A3 * from A where AID =? // List access to [0] .c.a1 [/ code>  

but I must be hibernate to make a request such as:

  select * One where in AID (?,?) // list [0]. Access to A3 and List [0] .c.a1  

-

How can I do this as a posting process for my executeQuery?

(And to better understand my problem, I have several links to the "A" unit - say N, which executes too many inquiries (at least 300 * N questions) and my Slow down the process).


Comments