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.  [ 3 posts ] 
Author Message
 Post subject: Help with lazyinstantiation 3.0
PostPosted: Mon Jun 20, 2005 10:06 pm 
Newbie

Joined: Mon Feb 07, 2005 7:57 pm
Posts: 9
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.0.3
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>

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

<hibernate-mapping
>
<class
name="net.sf.webfeeds.model.persistence.userfeed.UserFeed"
table="USER_FEED"
>

<id
name="id"
column="USF_ID_USERFEED"
type="java.lang.Long"
>
<generator class="identity">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-UserFeed.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<version
name="version"
column="VERSION"
type="java.util.Calendar"
/>

<property
name="title"
type="java.lang.String"
update="true"
insert="true"
column="USF_TITLE"
/>

<property
name="digest"
type="boolean"
update="true"
insert="true"
column="USF_DIGEST"
/>

<many-to-one
name="category"
class="net.sf.webfeeds.model.persistence.category.Category"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="CTR_ID_CATEGORY"
/>

<many-to-one
name="feed"
class="net.sf.webfeeds.model.persistence.feed.Feed"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="FDS_ID_FEED"
/>

<many-to-one
name="user"
class="net.sf.webfeeds.model.persistence.user.User"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="USR_ID_USER"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-UserFeed.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>

<?xml version="1.0" encoding="UTF-8"?>

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

<hibernate-mapping
>
<class
name="net.sf.webfeeds.model.persistence.category.Category"
table="CATEGORY"
>

<id
name="id"
column="CTR_ID_CATEGORY"
type="java.lang.Long"
>
<generator class="identity">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Category.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<version
name="version"
column="VERSION"
type="java.util.Calendar"
/>

<property
name="color"
type="java.lang.String"
update="true"
insert="true"
column="CTR_COLOR"
/>

<property
name="title"
type="java.lang.String"
update="true"
insert="true"
column="CTR_TITLE"
/>

<set
name="userFeeds"
lazy="false"
inverse="true"
cascade="delete"
sort="unsorted"
>

<key
column="CTR_ID_CATEGORY"
>
</key>

<one-to-many
class="net.sf.webfeeds.model.persistence.userfeed.UserFeed"
/>

</set>

<many-to-one
name="group"
class="net.sf.webfeeds.model.persistence.group.Group"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="GRP_ID_GROUP"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Category.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


Hello there! As you can check my mapping above I have a many-to-one relation with Feed. This pojo UserFeed is a Set (not a lazy one) in another class: Category. When I load a given category, it comes with the userFeeds, but the relation userFeed -> Feed is null. When accessing it I get "could not initialize proxy - the owning Session was closed". (this used to work on 2.1.7). What is happening? Does 3.0 comes with lazy many-to-one relationships???


Thanks

Vinicius


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 20, 2005 10:12 pm 
Newbie

Joined: Mon Jun 20, 2005 4:32 am
Posts: 4
Are you using spring's HibernateTemplate, it will close the session as early as possible.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 20, 2005 10:20 pm 
Newbie

Joined: Mon Jun 20, 2005 4:32 am
Posts: 4
I think I have got the answer, in hibernate-mapping-3.0.dtd, it has this define code :

Code:

<!ATTLIST hibernate-mapping default-lazy (true|false) "true">



set default-lazy = "false" and try again, good luck[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.