File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes tangled up with session management 101 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "tangled up with session management 101" Watch "tangled up with session management 101" New topic
Author

tangled up with session management 101

Stuart Rogers
Ranch Hand

Joined: Oct 02, 2008
Posts: 133
Greetings all,

I've created a standalone (not webapp) Java/Hibernate application, roughly patterned after the HelloWorld example from hibernate.org .
I'm trying to use the "thread-bound strategy" (should I be? Future bigger apps will be webapps on a Tomcat server w/o JNDI )
All looks good until execution when it starts throwing messages like "session already closed", etc.

my hibernate.cfg.xml contains:


my HibernateUtil.java :


my StateCodeDAOHibernate.java


my StateCodeDAO.java :


and finally my application class (containing main() ) :


I think my problem(s) lie in my HibernateUtil - there's quite a few to choose from on the 'net, all based on different examples under different assumptions.

Any and all help/suggestions/hints/fixes/constructive criticisms are welcome.

TIA,

Still-learning Steve
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
I noticed that you closed the session factory twice.

# sf.close();
# HibernateUtil.shutdown();


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: tangled up with session management 101
 
Similar Threads
Caching Issues with Hibnernate
[Hibernate] NoClassDefFoundError
Error in reading hibernate.cfg.xml after updating hibernate3.jar
hibernate session: to close or not to close
java.net.SocketException: Broken pipe