[ 1898050 ] PO.delete trx management bug

This commit is contained in:
Heng Sin Low 2008-02-20 17:20:13 +00:00
parent 7527c2e9b8
commit bb271ef34d
1 changed files with 155 additions and 125 deletions

View File

@ -2605,6 +2605,19 @@ public abstract class PO
} // processed
} // force
Trx localTrx = null;
boolean success = false;
try
{
String localTrxName = m_trxName;
if (localTrxName == null)
{
localTrxName = Trx.createTrxName("POdel");
localTrx = Trx.get(localTrxName, true);
m_trxName = localTrxName;
}
try
{
if (!beforeDelete())
@ -2635,13 +2648,7 @@ public abstract class PO
log.saveError("Error", errorMsg);
return false;
}
Trx localTrx = null;
String localTrxName = m_trxName;
if (localTrxName == null)
{
localTrxName = Trx.createTrxName("POdel");
localTrx = Trx.get(localTrxName, true);
}
//
deleteTranslations(localTrxName);
// Delete Cascade AD_Table_ID/Record_ID (Attachments, ..)
@ -2653,7 +2660,7 @@ public abstract class PO
.append(" WHERE ")
.append(get_WhereClause(true));
int no = DB.executeUpdate(sql.toString(), localTrxName);
boolean success = no == 1;
success = no == 1;
// Save ID
m_idOld = get_ID();
@ -2666,8 +2673,6 @@ public abstract class PO
}
else
{
if (localTrx != null)
success = localTrx.commit();
if (success)
{
// Change Log
@ -2711,9 +2716,6 @@ public abstract class PO
log.warning("Not deleted");
}
}
if (localTrx != null)
localTrx.close();
localTrx = null;
try
{
@ -2735,6 +2737,25 @@ public abstract class PO
success = false;
}
}
if (!success)
{
if (localTrx != null)
localTrx.rollback();
}
else
{
if (localTrx != null)
{
try {
localTrx.commit(true);
} catch (SQLException e) {
log.saveError("Error", e);
success = false;
}
}
}
// Reset
if (success)
{
@ -2744,6 +2765,15 @@ public abstract class PO
m_newValues = new Object[size];
CacheMgt.get().reset(p_info.getTableName());
}
}
finally
{
if (localTrx != null)
{
localTrx.close();
m_trxName = null;
}
}
// log.info("" + success);
return success;
} // delete