-
1. Re: how to rollback transactions without throwing exception on container?
joaobmonteiro Jun 23, 2008 3:13 PM (in response to gothmog)Hi,
Wich database are you using? Check if autocommit is enabled. It could cause problems like this.
Try to use an UserTransaction with begin/comitOrRollback.
Regards,
-
2. Re: how to rollback transactions without throwing exception on container?
jacob.orshalick Jun 24, 2008 5:36 PM (in response to gothmog)Why not just use MANUAL flush mode and only flush once the batch upload completes? In this way you don't have to worry about rolling back the transaction, instead simply avoid flushing the persistence context should an error occur. This just requires setting a message and returning null so the user is returned to the same view.
Note that this means all but the failed upload will be associated with the persistence context in the conversation meaning that a subsequent flush would persist those entities (this is nice for an accept/reject scenario). You can always clear the persistence context if this is not desirable.
Hope it helps.