|
From: <tri...@tr...> - 2003-10-16 13:41:41
|
Juergen, My understanding is that unless you explicitly call a commit on the JDBC connection, you should _never_ see any changes in the database. If you close the connection without calling rollback or committ, the transaction should roll back automatically. I suspect the reason there are changes made to the database is because the table is non-transactional. > If I understand correctly, a JDBC driver should behave the same: If a commit > has failed, rollback does not have to be invoked anymore. Would it actually > hurt if one still invoked rollback? Would that get ignored with most drivers, > or would it cause yet another exception, a la "transaction is already rolled > back" or "no transaction anymore"? 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. > I intend to fix the Hibernate transaction issue like this: First invoke flush > manually and treat it like data access, i.e. just commit if it succeeded, > else cause an explicit rollback. 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? > Aren't the semantics of Hibernate's commit > method a bit odd? Shouldn't it cause a rollback itself if the flush failed? I think they should cause a rollback if the flush failed, unless there is another transaction manager involved. Thomas |