-->
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: Advice on keeping session open in servlet context
PostPosted: Sun Sep 26, 2004 6:48 pm 
Newbie

Joined: Tue Jan 27, 2004 3:37 am
Posts: 4
Location: Mount Maunganui, New Zealand
Hi There

I've inherited an application using Hibernate 2.0 on Tomcat and MySQL for a struts-based community based website. Each Community has a Location, and each Location has a set of adjacent Locations and child Locations, like this:

<hibernate-mapping>
...
<class name="com.iwp.persistence.Location" table="LOCATION" >
<set name="adjacentLocations" lazy="true" table="LOCATION_LOCATION" order-by="locationID ASC" >
<key column="locationID" />
<many-to-many class="com.iwp.persistence.Location" column="adjacentLocationID" />
</set>

<list name="childLocations" cascade="all" lazy="true">
<key column="parentID" />
<index column="childIndex" type="long" />
<one-to-many class="com.iwp.persistence.Location" />
</list>
...

I have had to make the associations lazy for performance. There are a lot of locations, so again for performance I am storing them in the ServletContext, loading on server startup using a Struts plugin. The problem is that when doing this the session needs to be kept open while the application is running so that the lazy collections can be populated.

I am not entirely happy with this solution, because it seems to go against the idea of a session representing a users interaction with the database. It seems like a kludge to me.

Does anyone see any any problems associated with doing this? Can anyone suggest a better way to do this? Is there a way to re-associate another session with a lazy collection, because this would solve the problem more elegantly without too much pain.

Thanks in advance for any advice.

Peter Butler


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 26, 2004 8:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I'd rather take a look at the second level cache probably.


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.