-->
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: Cached Collections are not loaded (copied)
PostPosted: Thu Sep 15, 2005 4:23 am 
Newbie

Joined: Sun Feb 13, 2005 6:39 am
Posts: 11
Location: Belgium
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hi,

Im trying to use the QueryCache for tuning my queries.
Now when I activate read-write cache on all my Business Objects, and on all collections (all set lazy="true") for those business objects, and I then perform a Query all is cached as it should be.

The following is the extract of such a collection.

<bag name="functies" inverse="false" lazy="true" cascade="save-update">
<cache usage="read-write"/>
<key column="MDW_ID" property-ref="medewerkerId" />
<one-to-many class="Functie" />
</bag>


However when I Query again, and want to fetch the "functies" associations I got a
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: be.ikmo.core.model.Medewerker.functies - no session or session was closed
exception.

When I look deeper into the code, all data is retrieved the second time, but it fails to take a TypeFactory.deepCopy() as the updateability for the collections has a "false" value instead of a "true" as all other properties have.

I've been looking where I can define this Updateability on those collection, but was not able to find it.

Is there anybody who can help me out.
Thnx,
Nico





Hibernate version:3.05

Mapping documents:

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

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 5:04 am 
Newbie

Joined: Sun Feb 13, 2005 6:39 am
Posts: 11
Location: Belgium
The inverse="false" should be inverse="true"

and the definition of the many-to-one is

<many-to-one name="medewerker" class="Medewerker"
property-ref="medewerkerId" column="MDW_ID" insert="false" update="false" />


Hope this extra information will help to find a solution.

Regards,
Nico


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 8:42 am 
Newbie

Joined: Sun Feb 13, 2005 6:39 am
Posts: 11
Location: Belgium
Here are the involved mapping files.

The first file contains a Abstract class:
<hibernate-mapping package="be.ikmo.core.model">
<class name="Partij" abstract="true">

<!-- Cache Configuration -->
<cache usage="read-write" />

<id name="partijId" type="string">
<column name="ID" length="32" />
<generator class="uuid" />
</id>

<version column="DT_MOD" name="modificationDate"
type="timestamp" />
</class>
</hibernate-mapping>


Second mapping file containing the class extending the Abstract class and defining the Bag for its relation with the business objects defined in the third mapping file:
<hibernate-mapping package="be.ikmo.core.model">
<union-subclass name="Medewerker" table="V_MEDEWERKER" extends="Partij">

<bag name="functies" lazy="true"
cascade="save-update">
<key column="MDW_ID" property-ref="medewerkerId" />
<one-to-many class="Functie" />
</bag>

<property name="medewerkerId" type="string" update="false">
<column name="MDW_ID" length="32" unique="true"
not-null="true" />
</property>

</union-subclass>

</hibernate-mapping>



Third mapping file containing many-to-one relation:
<hibernate-mapping package="be.ikmo.core.model">
<class name="Functie" table="FUNCTIE" >
<!-- Cache Configuration -->
<cache usage="read-write"/>

<composite-id name="functieId" class="FunctieId">

<key-property name="functie" type="string">
<column name="FUNCTIE" length="20" />
</key-property>
<key-property name="datumVan" type="date">
<column name="DT_VAN" />
</key-property>
<key-property name="medewerkerId" type="string">
<column name="MDW_ID" length="32" />
</key-property>
</composite-id>

<version column="DT_MOD" name="modificationDate"
type="timestamp" />

<many-to-one name="medewerker" class="Medewerker"
property-ref="medewerkerId" column="MDW_ID" insert="false" update="true" />
</class>
</hibernate-mapping>



Hope that this give some more information.
Nico


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.