• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

tangled up with session management 101

 
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I noticed that you closed the session factory twice.

# sf.close();
# HibernateUtil.shutdown();
 
I'd appreciate it if you pronounced my name correctly. Pinhead, with a silent "H". Petite ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic