This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
1. The biggest issue is your private static final Session. Sessions are not thread safe. SessionFactories are.
2. config.buildSessionFactory() is deprecated as is probably evidenced by the strike through you most likely see in your IDE.
3. What is it are you hoping to accomplish with your exception handling? You might want to throw an exception in your create session and see the message you are actually throwing out on that exception.
Consider if you want to use one hibernate session through one user request(using same session across multiple DAOs). As far as I know it is not a wise decision to open and close session for every DB transaction.
Is it a web application? Then you might want to use same hibernate session in a single user session. If so where do you want to place your session?
Joined: Jun 05, 2010
Thanks William P O'Sullivan, Bill Gorder and Divya Janyavula for your replies.
Its a Windows application, created using swing and hibernate.
Can anyone explain the internal proceedings if i go for getCurrentSession? In my application, i haven't used cache. The whole application basically works on CRUD.