-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Shared collections and subqueries on member sets
PostPosted: Fri Apr 09, 2004 11:47 am 
Newbie

Joined: Wed Nov 26, 2003 3:03 pm
Posts: 9
Location: Denver, CO
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


Top
 Profile  
 
 Post subject: Found filters, still freaking out on shared collections
PostPosted: Fri Apr 09, 2004 12:08 pm 
Newbie

Joined: Wed Nov 26, 2003 3:03 pm
Posts: 9
Location: Denver, CO
OK, So I pour over documentation for an hour, find nothing, then post a silly question and find the filter interface almost immediately. At least it's Friday :).
Anyways, I've converted my subqueries to use filter and I'm still getting a shared collection exception. Does anyone know how to figure out which collection is being shared? I'm going to get the hibernate source and start debugging, but if anyone has tips, pleast let me know.

Thanks,

Derek


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.