mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
#390 - ENH: Add Change log mechanism for easy fine grained logging of insert, update, delete activity
This commit is contained in:
1 parent
46b158a0a0
commit
84190f3c2a
34 files changed
+1642
-84
No files matched your search
@@ -3,6 +3,9 @@ package com.avaje.ebeaninternal.server.transaction;
|
||||
import com.avaje.ebean.TransactionCallback;
|
||||
import com.avaje.ebean.bean.PersistenceContext;
|
||||
import com.avaje.ebean.config.PersistBatch;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform.OnQueryOnly;
|
||||
import com.avaje.ebean.event.changelog.BeanChange;
|
||||
import com.avaje.ebean.event.changelog.ChangeSet;
|
||||
import com.avaje.ebeaninternal.api.DerivedRelationshipData;
|
||||
import com.avaje.ebeaninternal.api.SpiTransaction;
|
||||
import com.avaje.ebeaninternal.api.TransactionEvent;
|
||||
@@ -10,7 +13,6 @@ import com.avaje.ebeaninternal.server.core.PersistRequest;
|
||||
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
|
||||
import com.avaje.ebeaninternal.server.lib.util.Str;
|
||||
import com.avaje.ebeaninternal.server.persist.BatchControl;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform.OnQueryOnly;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -19,7 +21,12 @@ import javax.persistence.RollbackException;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* JDBC Connection based transaction.
|
||||
@@ -133,6 +140,8 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
|
||||
protected boolean batchOnCascadeSet;
|
||||
|
||||
protected TChangeLogHolder changeLogHolder;
|
||||
|
||||
/**
|
||||
* Create a new JdbcTransaction.
|
||||
*/
|
||||
@@ -180,6 +189,19 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
return logPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBeanChange(BeanChange beanChange) {
|
||||
if (changeLogHolder == null) {
|
||||
changeLogHolder = new TChangeLogHolder(this, 100);
|
||||
}
|
||||
changeLogHolder.addBeanChange(beanChange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChangeLog(ChangeSet changesRequest) {
|
||||
manager.sendChangeLog(changesRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(TransactionCallback callback) {
|
||||
if (callbackList == null) {
|
||||
@@ -210,6 +232,9 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changeLogHolder != null) {
|
||||
changeLogHolder.postRollback();
|
||||
}
|
||||
}
|
||||
|
||||
protected void firePreCommit() {
|
||||
@@ -234,6 +259,9 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changeLogHolder != null) {
|
||||
changeLogHolder.postCommit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user