aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate Exception: Could not insert and JDBC Rollback failed.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Exception: Could not insert and JDBC Rollback failed.." Watch "Hibernate Exception: Could not insert and JDBC Rollback failed.." New topic
Author

Hibernate Exception: Could not insert and JDBC Rollback failed..

Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369
    
    1

I have written the following class to persist mapped POJOs to MySQL database.

My hibernate configuration file is set up as:


When i use this class, I get Hibernate Exceptions (occuring sporadically):
1. Could not insert[POJO.Logging]
2. JDBC rollback failed.

In most cases, the same code works like i expect it to. I understand that "could not insert" could be due to several reasons(bad data/ constraint violation); but the data populated in the POJO is generated by the application and is allegedly unique.

Q1.Could there be any other issue (like say...object state conflicts??) which could give rise to "insert" errors?

Q2.Assuming that, there was an exception in the try block, why is rollback failing?

Q3.What happens when the tx.commit(); statement fails; i mean how is the rollback handled?


Please help..
[ November 10, 2008: Message edited by: Monu Tripathi ]

[List of FAQs] | [Android FAQ] | [Samuh Varta]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10290
    
168

Monu,

Without seeing the entire exception stacktrace, we wont be able to know what might be wrong Please post the entire exception stacktrace.


[My Blog] [JavaRanch Journal]
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369
    
    1

I just captured the error message in my logs but not the entire stack trace.
Unfortunately, I can't recreate it as and when I'd like(this is all i can tell at the moment).

I'd appreciate any pointers or links that will help understand hibernate commits and rollback(in terms problems and issues that may surmise).

Thanks in advance...
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Without the stack trace there is not much you (or we) can do.

But this is a good Wiki entry about Hibernate transactions.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369
    
    1

Thanks for sharing the link.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate Exception: Could not insert and JDBC Rollback failed..