-->
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: Criteria by Example giving:owner not associated with session
PostPosted: Thu Oct 14, 2004 12:07 pm 
Newbie

Joined: Wed Oct 15, 2003 10:24 pm
Posts: 10
I've got an object model that utilizes Processes (a sub class of what were calling Tasks) which can have one to many Schedules underneath as children... see below for the mapping relationship.

I'm seeing a problem when getting Processes using the list method of the Criteria class filtering by Example (see below). Basically when Hibernate is flushing collections before retrieving my list on the second list call, it sees an unreachable item in the schedule collection that doesn't seem to be associated with my session. This throws an AssertionFailure with the message "owner not associated with session" from the call to SessionImpl.updateUnreachableCollection.

I know this may not be a whole lot to go on, but I'm hoping that someone might be able to give advice on where I could look to see how this collection's owner is getting lost.

- Paul


Hibernate version:
version 2.1.6

Mapping documents:
From Task.hbm.xml
<set
name="schedules"
lazy="true"
inverse="true"
cascade="all-delete-orphan"
sort="eg.ScheduleSequenceComparator"
>

<key
column="PROCESS_ID"
>
</key>

<one-to-many
class="eg.Schedule"
/>
</set>

From Schedule.hbm.xml
(note e.g.Process is a child of eg.Task)

<many-to-one
name="parentProcess"
class="eg.Process"
cascade="none"
outer-join="auto"
column="PROCESS_ID"
not-null="false"
/>



Code between sessionFactory.openSession() and session.close():

Calls this first....
lst = session.createCriteria(RootProjectProcess.class).addOrder(order).setFetchMode("predecessorTasks", FetchMode.EAGER).setFetchMode("schedules", FetchMode.EAGER).setFetchMode("refElements", FetchMode.EAGER).setFetchMode("fieldDefs", FetchMode.EAGER).add(ex).list();

Then calls this second....
lst = session.createCriteria(RootApprovalProcess.class).add(ex).list


Name and version of the database you are using:
SQL Server 2000


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 30, 2004 7:50 pm 
Newbie

Joined: Thu Nov 25, 2004 10:08 pm
Posts: 5
You can only load one collection eagerly in a single criteria query! If you have more then one you probably wanna switch to HQL.

Frank


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.