Hello all,
I have a couple of conceptual questions that i need to find out from anyone one out there who might be able to answer me:
1) Is there anyway that i can find out if a session.save has failed due to a unique constraint so that i can catch the exception and know that the save has failed due to some value that is meant to be unique in the database but it isnt, and not becos of any other error like size too big for the column? basically how do i differentiate a specific error from a host of errors that can possibly happen in a session.save()?
2) i understand from a previous posting from Gavin King that it is not possible for hibernate to automatically save a newly created object with a t.commit() in a transaction, the new object has to be saved in a sess.save() call. i also do know from experience that in a parent-child relationship, the child will need to be saved first before the parent. ok now the problem is that in order to save a newly created parent object with its child objects, i would have to save each child object individually first before saving the parent object, but since i cant save all of them in a t.commit() in one fell swoop and rollback if there are any errors, what would be the best way to mitigate the damage caused should a sess.save() half way down a series of sess.save() fails and some objects have already been saved and cannot be rollbacked since calling t.rollback doesnt rollback sess.save()s?
Best Regards,
Steward
|