I use Spring 3 and Hibernate 3.6 for developing a webapplication - Im new and Im wondering if I really understand how sessions are working.
Is it correct, that the Sessions between Server and Client, identified by a session id, are different from hibernate sessions?
The session between Server and Client is always a HttpSession.(?) When is it created? When a User logs in or also when an anonymous user requests a page (which is not secured)?
is there any connection between httpsession and hibernate-sessions? Are Hibernate Sessions created by a sessionfactory with no connection to a httpsession? Im not sure to which session hibernate is refering with a command like this:
this.sessionFactory.getCurrentSession().save(object);
this getCurrentSession()
: for how long is this hibernate session active? for the whole time a user is logged in? or for just one transaction (which can include multiple data-operations?)
Im so开发者_开发问答rry for this question which is maybe totally easy to answer, but most documentations are in english and if this is not ones mother tongue understanding is sometimes difficult (mainly because the word "session" is used so often)
thanks for helping me to understand this topic! :-)
Is it correct, that the Sessions between Server and Client, identified by a session id, are different from hibernate sessions?
Yes, completely different.
Reference: (javax.servlet) HttpSession
, (Hibernate) Session
The session between Server and Client is always a HttpSession.(?) When is it created? When a User logs in or also when an anonymous user requests a page (which is not secured)?
See Java EE Tutorial > Maintaining Client State
is there any connection between httpsession and hibernate-sessions?
No, although an OpenSessionInViewFilter
can make sure there is a Hibernate Session
available for every HTTP Request (One Hibernate Session per Request, not per Web Session).
Are Hibernate Sessions created by a sessionfactory with no connection to a httpsession?
Yes, usually.
Im not sure to which session hibernate is refering with a command like this: "this.sessionFactory.getCurrentSession().save(object);"
Hibernate Session
this "getCurrentSession()": for how long is this hibernate session active? for the whole time a user is logged in? or for just one transaction (which can include multiple data-operations?)
See Hibernate Reference > Session and Transaction Scopes
精彩评论