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: object navigation problems
PostPosted: Thu Nov 18, 2004 9:48 pm 
Regular
Regular

Joined: Tue Oct 12, 2004 9:02 am
Posts: 66
Location: Italy
I get a lazyInitializationException. The mapping are a many-to-many association, but i use 2 one-to-many association to implement it.

<class name=User...>
..
<set name="myItems" lazy="true" inverse="true" cascade="all-delete-orphan">
<key column="USER_ID" />

<one-to-many class="Sign"/>
</set>
</class>


<class name="Signed" ...
<many-to-one name="item" column="ITEM_ID" class="Item"/>
<many-to-one name="user" column="USER_ID" class="User"/>
</class>

<class name="Item"...
..
<!-- no one-to-many here because i don't need in my application...it is right? -->

<many-to-one name="category" column="cat_id" class="Category" />
</class>

In one session i do
Signed s = new Signed();
s.setItem(item);
s.setUser(user);
user.getMyItems().add(sign);


in the next session i do in a jsp:

<bean:write name="sign" property="item.title"/> (OK!)
<bean:write name="sign" property="item.category.description"/> (lazy exception!)

The session is open in my JSP, so why this lazy object initialization problem??
And this happens only when I add an item to the set "myItems" (in the user class) and in the next session I navigate on the object graph as i showed in the code above.


Top
 Profile  
 
 Post subject: Re: object navigation problems
PostPosted: Fri Nov 19, 2004 5:52 am 
Regular
Regular

Joined: Tue Oct 12, 2004 9:02 am
Posts: 66
Location: Italy
agori wrote:
In one session i do
Signed s = new Signed();
s.setItem(item);
s.setUser(user);
user.getMyItems().add(sign);


Incredible (for me), but if I do
user = dao.getUserById(user.getId());
before the code above everything is ok!

Instead yesterday i tried
session.update(utente);
and
session.lock(utente, LockMode.NONE);
wothout good results!

WHY?


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.