Hello,
I love cache... and I found either a bug or I use it wrong !!
Imagine this :
Person (id, name, getChildren(), getParents() );
PersonRelation (person_child_id, person_parent_id, int value);
this gives me PersonRelationPK .....
here is my problem.... I define queries in the xml file :
From Person
From PersonRelation
From Person p left join fetch p.children
From Person p left join fetch p.parents
then I do :
SESS1 = createSession()
for all queries Q, i++:
SESS1.getNamedQuery(Q).setCachable(true).setCacheRegion("HERE-" + i).list().iterator();
then I can do :
Person P = getPerson(ID=3)
for (Iterator iter = P.getChildren().iterator ; .....)
....
without problems.... (I means no SQL request done)
but if I close the Hibernate connection and create a new one :
Person P = getPerson(ID=3)
for (Iterator iter = P.getChildren().iterator ; .....)
....
for each relation, Hibernate does the following request :
select parent, child, type from personrelation where parent=? and child=?
what do I do wrong ??
please help me.... my cache would finally be ok :-)
|