Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transaction failure crashes program

 
Ali Shair
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a simple code and my insert fails due to not null but my program crashes. Even though insert call is in try catch block

At end of transaction ,it tries to commit transaction and my program crashes.

Is there any way, I can stop my program from crashing :-(

Any help is appreciated.


Service class



DAO class



Bean code



ApplicationContext




Exception Log is

 
Ali Shair
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has no one ever faced this issue. It is a very common scenario.

If you are trying to insert 3 records and 2nd one fail then hibernate does not insert 1 and 3 because they are in same transaction.

How could I get it done ? I still want to insert 1st and 3rd record even if 2nd one does fail.



 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The message suggests you are trying to insert a null value in a field that cannot be null. The field is name - check the value you are adding.


If you are trying to insert 3 records and 2nd one fail then hibernate does not insert 1 and 3 because they are in same transaction.

How could I get it done ? I still want to insert 1st and 3rd record even if 2nd one does fail.

This is transactions behaving as they are designed to. If the three inerts statements are not dependent on each other don't put them in the same transaction.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic