do not send autocommit to true (from the docu:
Enables autocommit for JDBC pooled connections (not recommended).
(
The Session is short living while the SessionFactory is long living.
Your right: opening a session for every operation (insert/delete/update) is not the way to go. Instead you open a Session for a "business operation" (e.g. loading a user, changing his password and storing it again).
What do you mean by "several users" are accessing the same DB ? Are there applications accessing the DB directly or are several users accessing the DB trough Hibernate ?
In the first case you probably do not want the 2nd level cache, in the second you just go trough hibernate and don't worry. Hibernate takes care that people do not see stale data (thats why you are starting/ending a TX)
I found a work-around: clearing the session (which is equivalent to closing and opening again).
You should really close the Session after your done. As far as i know the Session is associated with a
JDBC Connection which needs to be released after use (it might time out otherwise), also you do not want different Threads accessing the same Session as the Session is not
Thread safe.
pascal