wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Transaction failure crashes program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Transaction failure crashes program" Watch "Transaction failure crashes program" New topic
Author

Transaction failure crashes program

Ali Shair
Ranch Hand

Joined: Sep 30, 2001
Posts: 33
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

Joined: Sep 30, 2001
Posts: 33
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

Joined: Apr 14, 2004
Posts: 10336

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.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
 
subject: Transaction failure crashes program
 
Similar Threads
Running application on web start
Problem using EclipseLink -> org.springframework.dao.InvalidDataAccessApiUsageException
InvocationTargetException
can not deploy application!!!!
Anyone know what this Spring security error means?