httpsesssion versus hibernate getNewSession() relationship
Elanges waran
Greenhorn
Joined: Dec 13, 2007
Posts: 17
posted
0
Hi All,
I developed a web application used hibernate with Jsp and servlet . also I used a hibernateUtil for ORM to Database. In my application i used on servlet HttpSession session = request.getSession(); and in Session session = HibernateUtil.getNewSession() for execute our sql query. I want a clarification between httpseession and hibernate session. Kindly Reply in soon..
Thanks, K.Elanges
Regards,<br />K.Elanges
Walter Bernstein
Ranch Hand
Joined: Dec 19, 2007
Posts: 57
posted
0
HttpSession is a context object for a user in a web application. You can identify a user session by the sessionId (stored in a cookie or request parameter). You can store state in the session. Typically a session consists of many user requests. A session is destroyed on timeout, or manually (e.g. on logout). Typical scenario: user logs in, does some stuff, logs out.
"Hibernate session" is a bad name. A better name would have been UnitOfWork. The hibernate session is a context object for the hibernate framework. The session provides access to the db (query, criteria, ...). All objects you load via the hibernate session are registered in the hibernate session. Hibernate will take care to persist any changes made to the session's objects. Typically a hibernate session is a short living object (does'nt live longer than a user request).
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: httpsesssion versus hibernate getNewSession() relationship