amila733 wrote:
sess.createCriteria(T.class,"t")
.createCriteria("V","v")
.add( Restrictions.eq("t.id",value)).list();
hmm, this leads to the same query (and I think it should). I tried to change it to:
sess.createCriteria(T.class,"t")
.createCriteria("V","v")
.add( Restrictions.eq("v.id",value)).list();
but that doesn't quite work. The "value" that you provide here should actually come out of the "mother" table. So there is a table T and a view V and an association (that is modeled as a table). I would need to say: Get entity X from T where T = myValue and all the entities Y from V where V.kdnr = T.kdnr. Then Hibernate joins as posted in the first paragraph, but it should try to join "the other way around" (because that would be faster). Any ideas on how to do that?
My workaround so far: Select the entity X from T and load all entities Y with a criteria -> 2 selects.