I have the following...
Code:
public class A
{
private Set items;
}
private void foo()
{
A a = (A) session.get(A.class, ...);
}
After foo runs, "a" is not garbage-collected. There is an equal instance but referenced elsewhere in a collection that exists as long as the application is running.
So, if I run foo 5 times, I have 6 instances of A (one which is not supposed to be GCed), even after forcing GC (through a profiler).
Only when I remove the instance of A in the collection, then will all 6 instances by GCed.
Am I not using Hibernate correctly?