-->
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.  [ 5 posts ] 
Author Message
 Post subject: Open Session in View pattern doubt - help
PostPosted: Tue May 13, 2008 10:09 am 
Newbie

Joined: Tue May 13, 2008 10:01 am
Posts: 8
From this link: http://www.hibernate.org/43.html, I read the following:

Using an interceptor

Line 1 -
If you implement your Session handling with Hibernates built-in support for automatic Session context management, see Sessions and transactions, you have half of the code for this already. Now you only need some kind of interceptor that runs after the view has been rendered, and that will then commit the database transaction, hence close the Session.

Line 2 -
In other words, in most applications you need the following: when an HTTP request has to be handled, a new Session and database transaction will begin. Right before the response is send to the client, and after all the work has been done, the transaction will be committed, and the Session will be closed.

These lines contradict each other. One says, interceptor runs 'session closed after the view has been rendered'. Second says 'session closed before the response sent to the client'.

Can someone please explain this to me.

Thank you.

_________________
Best wishes


Top
 Profile  
 
 Post subject: Some more info
PostPosted: Tue May 13, 2008 11:23 am 
Newbie

Joined: Tue May 13, 2008 10:01 am
Posts: 8
I learned and believed filters complete running before the response is sent and before the page is rendered.

Is the author talking about response of the earlier request? I mean closing the open session of request1 while sending the response for request2?

I feel like I am missing something great here.

Most of you guys seem to have already landed in good amount of development with Hibernate. You might have implemented in Web application, this hibernate session. Can you give me some tips, if I like to access objects from hibernate-sessions (where lazy-loading is enabled) to render in the pages, how we are maintaining the hibernate-session?

_________________
Best wishes


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 13, 2008 3:49 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
I think you might just be getting hung up on the verbage here.

Essentially, this pattern involves capturing an incoming request, and kicking off your Session. Then, when all is said and done, and the JSPs have run their course and generated all of their markup, the session's transaction is committed.

The terminology of the view being rendered may be confusing you. I think this just implies that the JSP files have finished their processing, but the actual content hasn't been flung back to the requester.

Essentially, a ServletFilter should accomplish this fairly easily.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Thank you...
PostPosted: Tue May 13, 2008 6:50 pm 
Newbie

Joined: Tue May 13, 2008 10:01 am
Posts: 8
Cameron McKenzie wrote:
I think you might just be getting hung up on the verbage here.

Essentially, this pattern involves capturing an incoming request, and kicking off your Session. Then, when all is said and done, and the JSPs have run their course and generated all of their markup, the session's transaction is committed.

The terminology of the view being rendered may be confusing you. I think this just implies that the JSP files have finished their processing, but the actual content hasn't been flung back to the requester.

Essentially, a ServletFilter should accomplish this fairly easily.


Summary points:
Rendering the View means I think generating the view content;
Filter (servlet) process sits after we complete generating the view content;
Once we generate the view content completely we do not need hibernate session anymore.
Sending the response is of course after the filter closes the Hibernate session.

I just did not think it right.

Thanks Cameron.

_________________
Best wishes


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 14, 2008 10:13 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
What's important isn't always what is said. What is important is what they mean when they say something. ;)

One of my biggest issues is that people keep doing what I tell them to do, and not what I want them to do. It's what I want them to do that is important.

Kindest regards!

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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