-->
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.  [ 4 posts ] 
Author Message
 Post subject: Basic Web Design Question...
PostPosted: Sun Jan 25, 2004 3:17 am 
Newbie

Joined: Wed Jan 21, 2004 1:29 am
Posts: 1
Sorry if this is a FAQ here, but I couldn't find the answer after some searching.

I have a simple web app (using Struts). I'm using the ServletFilter pattern for session management. I display lists of Widgets and I can add/remove them from a Cart. I currently display the Widgets in a form with a checkbox for each one. The value of the checkbox is the Widget's ID (also its primary key). I'd like to know people's thoughts on how to best implement this with hibernate. I see a few options.

1) Put the list of Widgets in the request (letting them go out of scope with the render of the jsp), when the post comes back to my Action, do this:
for id in idList
Widgets w = session.load( Widget.class, id );
Cart.getWidgets().add( w );
done
Note: This seems to work fine, but I'm wondering if its the best way.

2) Put the list of Widgets in the httpsession, so that when the form is submitted I can avoid the load step in #1.
-Can I relate objects from an invalid session into an object with a valid/different session?
-If I need to call session.load( w )(or update or refresh), is this any faster/better than session.load(Widget.class, id ) (aside form the obvious Object creation)?
-I don't really want to put things in the httpsession, but it looks like Spring could help with avoiding that.

3) Is there anyway to avoid reinstiating/repopulating Widgets just to add/remove them?
-Is this a silly question since hibernate will optimize my insertions for me?

4) Are there any other options to consider?


Thanks
-Paul

p.s. I've been extremely impressed by my ability to generate mappings/objects from a legacy database (with middlegen) and become productive working with those objects in an incredibly short ammount of time. Keep up the great work.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 25, 2004 7:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Caching solves/helps many of the reload issues like yours. Alternatively, session disconnect and reconnect of the held objects can be an affective approach. I don't use this approach (much) but Christan does and it is an outstanding hibernate feature. I don't use struts so not sure what the limitations if any are - try both approaches in a small test and see how it works out for you.

BTW: Thanks for the Middlegen feedback it is appreciate.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 25, 2004 7:52 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Regarding the "long session" approach (disconnect/reconnect), I just did a short consulting job for a large retail company where we used this approach to help achieve a performance improvement of perhaps two orders of magnitude. Their functionality was slightly unusual, but it demonstrates the power of this feature.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 2:22 am 
Regular
Regular

Joined: Tue Sep 30, 2003 11:27 am
Posts: 60
Location: Columbus, OH, USA
David/Gavin/Christian, is there a link to info about this "long session" approach? I'm currently (and successfully) using "Session in View" but am interested in contrasting the two. Thanks!
Scott

P.S. Stellar product you have here gentlemen!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.