Message:
A new issue has been created in JIRA.
---------------------------------------------------------------------
View the issue:
http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-558
Here is an overview of the issue:
---------------------------------------------------------------------
Key: HB-558
Summary: ODMG: Tx.abort() will fail after an unsuccessfull Tx.commit()
Type: Bug
Status: Unassigned
Priority: Major
Project: Hibernate2
Components:
core
Versions:
2.0.3
Assignee:
Reporter: Oliver Gries
Created: Wed, 17 Dec 2003 4:56 AM
Updated: Wed, 17 Dec 2003 4:56 AM
Description:
As far as I saw the current CVS versions this bug will affect newer versions than 2.0.3 as well.
Problem
=======
With the current implementation of the commit() method in the class Transaction, no abort/rollback is possible, due to the use of finally and setting the transaction variable tx to null, even if the commit fails.
Solution
========
Remove the finally statement in commit() e.g.:
public void commit() {
database.disassociateThread();
try {
if (tx!=null) tx.commit();
// if we are here, we were successfull
tx=null;
try {
session.close();
}
catch (HibernateException he) {
throw new ODMGRuntimeException( he.getMessage() );
}
}
catch (HibernateException he) {
throw new ODMGRuntimeException( he.getMessage() );
}
}
Improvements
============
Could you please as well improve the implementation code of
Database.getSession()
Implementation.currentTransaction()
Transaction.checkpoint()
in a way, that NullpointerExceptions caused ba uninitialized variables will not be thrown, even if you call those methods outside an transaction context.
OLD:
----
public Session getSession() {
return currentTransaction().getSession();
}
BETTER:
-------
public Session getSession() {
Transaction aTx = currentTransaction();
if (aTx != null)
return aTx.getSession();
else
return null;
}
Thanks
Oliver
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
|