Hibernate:3.0
Database: Oracle 10g
I have an application using Spring and Hibernate on top of an Oracle 10g database that is performing an unexpected number of transactions. I have the following classes:
Code:
public MatchService
{
private IBatchDAO mBatchDAO
private IMatchRecordDAO mMatchRecordDAO
private Batch getNextBatchForProcessing()
{
Batch batch = mBatchDAO.getNextBatch();
if( batch != null )
{
batch.setStatus( Batch.STATUS_PROCESSING );
mBatchDAO.storeBatch( batch );
}
return batch;
}
private void processBatch( Batch batch )
{
MatchTrx trx = new MatchTrx( mBatchDAO, mMatchRecordDAO );
trx.processBatch( batch );
batch.setStatus( Batch.STATUS_COMPLETE );
mBatchDAO.storeBatch( batch );
}
}
public MatchTrx
{
private IBatchDAO mBatchDAO;
private IMatchRecordDAO mMatchRecordDAO;
public MatchTrx( IBatchDAO batchDAO, IMatchRecordDAO matchDAO )
{
mBatchDAO := batchDAO;
mMatchRecordDAO := matchDAO;
}
public void processBatch( Batch batch )
{
MatchRecord rec = mMatchRecordDAO.getMatchRecord( batch.getRecordID();
rec.updateFromBatch( batch );
mMatchRecordDAO.deleteOldStuff( rec );
//... code here creates new stuff ...
mMatchRecordDAO.storeNewStuff( rec );
}
}
The MatchService class is wrapped with a transaction proxy bean using Spring, with both public methods declared as transactions. The problem is, when matchService.processBatch() is called, the operations appear to be applied as separate transactions. When the app is terminated in the middle of processBatch, I have found repeatable instances where the call to rec.updateFromBatch( batch ) has updated the database, but any changes made by mMatchRecordDAO.deleteOldStuff( rec ) have been rolled back.
Cany anyone give me some hints about what might be happening here?
Thanks,
Ben