mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-13 06:42:57 +00:00
#2134 - Modify ChangeLog to send the last set of changes Pre Commit (rather than post commit). Expose this for spring transactions.
This commit is contained in:
1 parent
e9081a176f
commit
1bdc6d8f7f
8 files changed
+71
-23
No files matched your search
@@ -319,6 +319,11 @@ public interface SpiTransaction extends Transaction {
|
||||
*/
|
||||
boolean isSkipCacheExplicit();
|
||||
|
||||
/**
|
||||
* Fire pre commit processing/listeners.
|
||||
*/
|
||||
void preCommit();
|
||||
|
||||
/**
|
||||
* Fire post commit events and listeners.
|
||||
*/
|
||||
|
||||
@@ -418,6 +418,11 @@ public abstract class SpiTransactionProxy implements SpiTransaction {
|
||||
transaction.flushBatchOnCollection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preCommit() {
|
||||
transaction.preCommit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postCommit() {
|
||||
transaction.postCommit();
|
||||
|
||||
+5
@@ -586,6 +586,11 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preCommit() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postCommit() {
|
||||
// do nothing
|
||||
|
||||
@@ -373,6 +373,9 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
|
||||
private void firePreCommit() {
|
||||
withEachCallback(TransactionCallback::preCommit);
|
||||
if (changeLogHolder != null) {
|
||||
changeLogHolder.preCommit();
|
||||
}
|
||||
}
|
||||
|
||||
private void firePostCommit() {
|
||||
@@ -981,9 +984,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
* Batch flush, jdbc commit, trigger registered TransactionCallbacks, notify l2 cache etc.
|
||||
*/
|
||||
private void flushCommitAndNotify() throws SQLException {
|
||||
internalBatchFlush();
|
||||
firePreCommit();
|
||||
// only performCommit can throw an exception
|
||||
preCommit();
|
||||
performCommit();
|
||||
postCommit();
|
||||
}
|
||||
@@ -994,6 +995,12 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||
notifyCommit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preCommit() {
|
||||
internalBatchFlush();
|
||||
firePreCommit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a commit, fire callbacks and notify l2 cache etc.
|
||||
* <p>
|
||||
|
||||
+1
-1
@@ -190,7 +190,7 @@ public class JtaTransactionManager implements ExternalTransactionManager {
|
||||
|
||||
@Override
|
||||
public void beforeCompletion() {
|
||||
transaction.flush();
|
||||
transaction.preCommit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -88,6 +88,11 @@ class NoTransaction implements SpiTransaction {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preCommit() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postCommit() {
|
||||
// do nothing
|
||||
|
||||
@@ -56,20 +56,31 @@ public class TChangeLogHolder {
|
||||
* Add a bean change to the change set.
|
||||
*/
|
||||
public void addBeanChange(BeanChange change) {
|
||||
|
||||
changes.addBeanChange(change);
|
||||
if (++count >= batchSize) {
|
||||
// we hit the batch size so send what we have knowing
|
||||
// that the transaction has not completed yet and
|
||||
// reset the changes and count
|
||||
owner.sendChangeLog(changes);
|
||||
changes = new ChangeSet(transactionId, ++batchId);
|
||||
count = 0;
|
||||
sendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendChanges() {
|
||||
owner.sendChangeLog(changes);
|
||||
changes = new ChangeSet(transactionId, ++batchId);
|
||||
count = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* On post commit send the changes we have collected.
|
||||
* Send the changes held prior to transaction commit.
|
||||
*/
|
||||
public void preCommit() {
|
||||
sendChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* On post commit send the changes we have collected. This should be
|
||||
* only the COMMITTED state and with all changes sent prior to commit.
|
||||
*/
|
||||
public void postCommit() {
|
||||
changes.setTxnState(TxnState.COMMITTED);
|
||||
|
||||
Reference in new issue
Block a user