Javid Jamae wrote:No, keep the SessionFactory in a singleton, then get the session using sessionFactory.getCurrentSession() to get the current session for the thread that you're in.
Read the first chapter of the Hibernate documentation.
The transaction boundaries depend on how long your transactions are. Typically you manage one per request. In a Web-based app, you might start and end the transaction in a ServletFilter.
Thanks for your Help.
So you mean, get a new session instance from the sessionFactory and a new transaction from the session in every method and i dont need to close them untill i actually use the DAO in a
servlet or so??
bsically thats what i have:
Please correct me if i m doing anything wrong.
Thanks again.