Quote:
Is this the way Hibernate works?
I guess Yes, and I have also an explanation for this:
-usually when you get a persistent collection i.e. by calling parent.getChilds()
then the query (SELECT * FROM CHILDREN WHERE PARENT_ID = <SOMEID> ) is executed
and the result is stored in the persistent collection.
-further calls of parent.getChilds() within the same persistent context will not execute the query again, as the persistent collection is already filled (initialized) and this is good.
-the persistent collection representing the parent-child relationship cannot be referred by the proxy-object.
-only the real implementation (the de-proxied instance) can keep a reference the persistent collection
-for this reason I guess, hibernate has to get the real implementationof the proxy by calling
SELECT * FROM PARENT WHERE ID = <SOMEID>