|
From: <jue...@we...> - 2003-10-16 13:57:55
|
> I think the exception is thrown during execute on some statement and = not the actual commit call to the JDBC connection, so at this point the = transaction is still active and a rollback would make sense. Additional rollback calls = on a JDBC connection should not cause any problems - you are basically = rolling back a new transaction that has not had any work performed. Of course, in the case of a flushing failure a rollback call makes = sense. But what if the Connection.commit call fails? Does it add any = value to additionally invoke rollback then? > I might be wrong here (have not looked at the code), but my impression = is that the Spring code is not actually managing the transaction - it is = delegating to Hibernate to manage the transaction. If that is the case, then I would = see what the Hibernate guys think about this and have them add a rollback call if = the flush fails. In the mean time I would leave it as it is since the = transaction should be rolled back either way barring an explicit commit call on the connection itself. What dou you mean by "cause an explicit rollback" - = call rollback on the connection or ask Hibernate to roll back? Right, it delegates to the Hibernate transaction. We can easily solve = the issue by explictly calling Session.flush before invoking = Transaction.commit, wrapping the flush call with its own try/catch block = that invokes Transaction.rollback if it fails (not Connection.rollback). = If the flush succeeds, we'll invoke Transaction.commit, *not* invoking = Transaction.rollback if there's a failure. The additional flush in = Transaction.commit will then not issue any SQL statements anymore; a = failure can thus be attributed to the actual commit call. > I think they should cause a rollback if the flush failed, unless there = is another transaction manager involved. Someone else has already opened the discussion on the Hibernate forum = :-) A Spring developer list subscriber has quoted my mail from yesterday = there; I've already added additional comments. Juergen |