[hibernate-dev] Hibernate + Oracle RDB 7.1
Rehnman Martin
Martin.Rehnman at lotterien.at
Wed Jun 13 09:12:32 EDT 2007
Hi,
We have discovered a minor problem within JDBCtransaction.java when
using Oracle RDB 7.1,
the database transaction is not automatically rollbacked by the database
on commit failures,
the client has to send a rollback over the JDBC-connection in that case.
When no rollback is sent,
the database transaction will still be open and associated with a
JDBC-connection when the connection is returned
to the connection pool. At another time some other client transaction
will get this connection from the pool with
an open database transaction which then will fail. We have solved this
problem by changing JDBCTransaction in this way:
private boolean rollbackAfterCommitFailed = false;
public void setRollbackAfterCommitFailed(boolean
rollbackAfterCommitFailed) {
this.rollbackAfterCommitFailed =
rollbackAfterCommitFailed;
}
private void commitAndResetAutoCommit() throws SQLException {
try {
jdbcContext.connection().commit();
} catch (SQLException e) {
// Extension for Oracle-RDB: Rollback after
failed Commit
if (rollbackAfterCommitFailed) {
try {
log.error("Rollback after
Commit-Failure");
jdbcContext.connection().rollback();
} catch (SQLException s) {
log.error("Exception during
Rollback", s);
}
throw e;
}
finally {
toggleAutoCommit();
}
}
In the JDBCTransactionFactory we added following:
private boolean rollbackCommitFailures; // Property
hibernate.transaction.rollback_after_commit_failure
public Transaction createTransaction(JDBCContext jdbcContext,
Context transactionContext) throws HibernateException {
JDBCTransaction trans = new JDBCTransaction(jdbcContext,
transactionContext);
trans.setRollbackAfterCommitFailed(rollbackCommitFailures);
return trans;
}
/** {@inheritDoc} */
public void configure(Properties props) throws HibernateException {
rollbackCommitFailures = PropertiesHelper.getBoolean(
Environment.TRANSACTION_ROLLBACK_COMMIT_FAILURES,
props,false);
}
It would be nice to have this little problem solved in future Hibernate
releases.
I also really would like to see Oracle RDB in the list of supported
databases, for every new
Hibernate Release I have to compile/add RdbDialect.java (got it from
HP/Oracle) to the jar.
Regards
Martin
Oesterreichische Lotterien Gesellschaft m.b.H., Rennweg 44, A-1038 Wien,
FN 54472 g, Handelsgericht Wien, DVR-Nr: 0476706
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-dev/attachments/20070613/971f488c/attachment.html
More information about the hibernate-dev
mailing list