• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session is closed.

 
Arjun Abhishek
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

This is the method i that gives error. I have session as a field and is initialized at the constructor of the class


When I call this method in a for loop with a string array.


The first insert in the table happens. while the second insert, I get error, "Exception in thread "main" org.hibernate.SessionException: Session is closed!"

Please let me know why this happens.

 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure how you get the Session, but if you get it from getCurrentSession(), the Session will be automatically closed when you end the transaction, either commit or rollback.

Maybe that's the reason why you got that exception.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic