I think there might indeed a hole in the algorithm.
But in a nutshell the algorithm is as follow:
-
do a criteria query selecting all matching ids
-
create a proxy for all matching elements (session.load to be specific)
All elements loaded from the previous query should be returned as materialized object (i.e. not an uninitialized proxy) when doing session.load. Apparently you might have found a case where this is not the case. I am not quite sure why the 2nd level cache would influence that but maybe.
Hibernate ORM does not materialize the object
|