aspose file tools
The moose likes Object Relational Mapping and the fly likes org.hibernate.TransactionException: Transaction not successfully started Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "org.hibernate.TransactionException: Transaction not successfully started" Watch "org.hibernate.TransactionException: Transaction not successfully started" New topic
Author

org.hibernate.TransactionException: Transaction not successfully started

Bai Shen
Ranch Hand

Joined: Sep 24, 2008
Posts: 323
I keep getting this exception and I'm not sure why.

I have a servlet that gets an object from the database using hibernate and places it in the web session. Then later, another servlet retrieves the object from the web session, modifies it, and saves it back to the database using hibernate.



After the o2 assignment, I set some values, call save, and then commit. However, it never runs those AFAIK. I have a log statement before and after the load command, and only the one before gets called.

I tried it without the load statement, but then I get an error during the save.

Any ideas what I'm doing wrong? Should I just do a query instead of the load?
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4967


You need to both start and commit your transaction.

session.beginTransaction();

session.getTransaction().commit();




Introductory Hibernate Tutorial

-Cameron McKenzie

Author of Hibernate Made Easy, What is WebSphere???, JSF 2.0 Made Easy and the SCJA Certification Guides
Bai Shen
Ranch Hand

Joined: Sep 24, 2008
Posts: 323
Hmm. I could have sworn I originally had it set up that way and it didn't work.

I'm not sure what I did wrong, but by adding a beginTransaction call, everything seems to be working now. Thanks.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: org.hibernate.TransactionException: Transaction not successfully started
 
Similar Threads
toString() on Integer class
Object References
Priority Queue
Native SQL: Left outer Join returns wrong data
arrays and garbage collection