-->
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: Open Session in View: Enforce readonly before View execution
PostPosted: Fri Jul 01, 2005 6:06 am 
Regular
Regular

Joined: Sun May 08, 2005 2:48 am
Posts: 118
Location: United Kingdom
In your experience would it make sense to mark the HibernateSession object as being read-only at the end of your Controller's execution in MVC design pattern.

So that the View can only read data with Hibernate to do its work. When I say mark read-only I mean no new write methods can be called on the session after this point. This does not affect any transactional flushing that might not have taken place yet, since those write's were . This flag would also need to be able to be cleared, so that another request in the same session could continue to work later.

This is just to ensure that the View code is never able to modify application data and emit warnings/errors if it even tried.

Does what I'm getting at make sense to you ?

Does Hibernate have any code to enforce this policy ?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 6:26 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Just wrapp hibernate session with stuff similar to DAO and " another request in the same session could continue to work later " must never happen, open and close hibernate session in filter or in "controler", requests work concurrently.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 7:52 am 
Regular
Regular

Joined: Sun May 08, 2005 2:48 am
Posts: 118
Location: United Kingdom
baliukas wrote:
" another request in the same session could continue to work later " must never happen.


I thought HibernateSession's can be retained across multiple-requests, this is an extension to the Open Session in View, where the view can use the session to construct the response but the session has not finished yet (not in the filter run for of the THAT request/response anyhow).


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 9:55 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
This stuff is related to concurrency control, if you want to reuse hibernate session and persistent object instances for many HTTP requests ( stuff is stored in HTTP session) then you must synchronize stuff and manage concurrency control yourself (think many times before to do it in web application).
"Open Session in View" maps hibernate session to thread/request and closes hibernate session after response is send, it makes lazy loading work in view, there is nothing more or less in this pattern.


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.