Hello,
I'm using hibernate for a simple app where I have the following structure (simplified):
Code:
class A
{
Set overrides; // (set of class B)
}
class B
{
Date startTime;
Date endTime;
}
I have used the session to load an instance of class A (myA), then I want to query the set of overrides to find which ones cover a certain time:
Code:
List results = session.find("SELECT override FROM A AS a join a.overrides as override WHERE a.id = ? AND override.startTime <= ? AND override.endTime >= ?",
new Object[] {myA.getId(), time, time},
new Type[] {Hibernate.LONG, Hibernate.TIMESTAMP, Hibernate.TIMESTAMP});
I am getting an exception: "Found shared references to a collection". Is this because I have already loaded the instance of A? The exception message makes it sound like I have multiple copies of the whole "overrides" Set, but really I only want a subset. Or is it because the subset and the full set share members? I would very much like to be able to use Hibernate for a subquery because iterating through the existing myA instance to determine which ones cover seems like it would be a bad idea.
Thanks,
Derek