I am trying to delete User based on userId but getting message "org.hibernate.HibernateException: get is not valid without active transaction"
org.hibernate.HibernateException: get is not valid without active transaction
Monica, all methods of org.hibernate.Session should be called within active transaction.
You need to get current session then begin transaction only then use org.hibernate.Session then commit transaction then close session.
Probably all methods of org.hibernate.Session are not executed when you call them but WHEN transaction is committed (line 13 in your code).
True person is moral, false is right!
Joined: Jul 07, 2012
Thanks. It worked.
subject: getting message "get is not valid without active transaction" while trying to delete using Hibernate