Is it a good idea to close and open hibernate sessions frequently?
Posted
by Gaurav
on Stack Overflow
See other posts from Stack Overflow
or by Gaurav
Published on 2010-04-15T05:52:59Z
Indexed on
2010/04/15
6:03 UTC
Read the original article
Hit count: 216
Hi,
I'm developing an application which requires that state of entities be read from a database at frequent intervals or triggers. However, once hibernate reads the state, it doesn't re-read it unless I explicitly close the session and read the entity in a new session.
Is it a good idea to open a session everytime I want to read the entity and then close it afterwards? How much of an overhead does this put on the application and the database (we use a c3p0 connection pool also)?
Will it be enough to simply evict the entity from the session before reading it again?
© Stack Overflow or respective owner