-->
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.  [ 1 post ] 
Author Message
 Post subject: problem migrating recursive relation from hibernate2->3.1
PostPosted: Mon Mar 06, 2006 2:32 am 
Newbie

Joined: Thu Jan 08, 2004 8:57 pm
Posts: 6
Basic idea is to have Categories within Categories within Categories. Sub Categories can have only one parent Category. A parent Category can have multiple sub categories.


After querying back a category cat (and close the session), The Application needs to know if the category is top level category, where parent is null, the codes is something

if (cat.getParentCat() == null)
{
do something
}

This works fine currently in Hibernate 2.0

However, when I migrate my app to hibernate 3.1.2, it complains the "session has been closed"

My question here is why hibernate need to do the query again? I set the lazy to false.



The mapping is something like:


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="au.com.mycpmpany.myproject.entities.Category" table="category">
<id name="id" >
<generator class="native"/>
</id>

<property name="name" type="string"/>
<property name="description" type="string"/>

<many-to-one name="parentCat" class="au.com.mycpmpany.myproject.entities.Category"
column="parentId" lazy="false"/>

</class>
</hibernate-mapping>


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

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.