-->
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: Struts and Session
PostPosted: Sun Nov 26, 2006 7:40 am 
Newbie

Joined: Tue Jul 25, 2006 12:03 am
Posts: 3
Hi,

I've been creating some application with struts and hibernate, and I have some weird behavior when saving the items.

First I followed the Open Session in View (http://www.hibernate.org/43.html) to implement the filter for opening/closing transaction. But I noticed that sometimes the data is not written to the database. So I googled it, and some people say that session needs to be closed at the end after the transaction is committed. (For some reason, the sample code provided by Open Session in View does not close the session). So I tried to modify the code and close the session when the transaction is commited. But everytime I do that, I get exception says "Session is closed!".

If I am using struts and developing web application, I don't have to close the session?

If so, is there anything I need to be careful about so that all values are written to the database? Most of the time, the data is written to the database without problem, but sometimes, very rarely though, the data is not.

Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 27, 2006 2:18 am 
Senior
Senior

Joined: Sat Jul 17, 2004 5:16 pm
Posts: 143
flush() on the Session before committing


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 27, 2006 2:57 am 
Newbie

Joined: Tue Jul 25, 2006 12:03 am
Posts: 3
Hi,

Thanks for the reply.

I did flush the session before commiting. But it still sometimes writes to the database and sometimes doesnt write to the database. (especially on many-to-many relationship)


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.