Beginner |
 |
Joined: Thu Aug 19, 2004 2:33 pm Posts: 30 Location: CA, USA
|
The problem with catching the constraint violation is determining when it will be thrown. If you are using the Session In View and GenericDAO patterns where your transaction is being handled outside your DAO and the session flushing is set to auto, the exception will usually be thrown when you commit your transaction, not when you issue the save() or saveOrUpdate().
So if you want to catch the exception, make sure you call session.flush() so you know the DML statement has been run against the database.
|
|