Is it a good idea to close and open hibernate sessions frequently?
- by Gaurav
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?