mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
#671 - ENH: Add support for @View and extra-ddl.xml to nicely support entity beans based on views
This commit is contained in:
1 parent
69c2810fbe
commit
81531b6cda
48 files changed
+1187
-255
No files matched your search
@@ -84,9 +84,9 @@ public final class PostCommitProcessing {
|
||||
/**
|
||||
* Notify the local part of L2 cache.
|
||||
*/
|
||||
void notifyLocalCache() {
|
||||
void notifyLocalCache(boolean viewInvalidation) {
|
||||
processTableEvents(event.getEventTables());
|
||||
cacheChanges = event.buildCacheChanges();
|
||||
cacheChanges = event.buildCacheChanges(viewInvalidation);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,7 +149,7 @@ public final class PostCommitProcessing {
|
||||
return new Runnable() {
|
||||
public void run() {
|
||||
if (cacheChanges != null) {
|
||||
cacheChanges.apply();
|
||||
manager.processViewInvalidation(cacheChanges.apply());
|
||||
}
|
||||
localPersistListenersNotify();
|
||||
notifyCluster();
|
||||
|
||||
@@ -27,6 +27,7 @@ import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
@@ -104,6 +105,8 @@ public class TransactionManager {
|
||||
*/
|
||||
private final ChangeLogListener changeLogListener;
|
||||
|
||||
private final boolean viewInvalidation;
|
||||
|
||||
/**
|
||||
* Create the TransactionManager
|
||||
*/
|
||||
@@ -113,6 +116,7 @@ public class TransactionManager {
|
||||
this.persistBatch = config.getPersistBatch();
|
||||
this.persistBatchOnCascade = config.appliedPersistBatchOnCascade();
|
||||
this.beanDescriptorManager = descMgr;
|
||||
this.viewInvalidation = descMgr.requiresViewEntityCacheInvalidation();
|
||||
this.changeLogPrepare = descMgr.getChangeLogPrepare();
|
||||
this.changeLogListener = descMgr.getChangeLogListener();
|
||||
this.clusterManager = clusterManager;
|
||||
@@ -398,7 +402,7 @@ public class TransactionManager {
|
||||
}
|
||||
|
||||
PostCommitProcessing postCommit = new PostCommitProcessing(clusterManager, this, transaction);
|
||||
postCommit.notifyLocalCache();
|
||||
postCommit.notifyLocalCache(viewInvalidation);
|
||||
backgroundExecutor.execute(postCommit.backgroundNotify());
|
||||
|
||||
for (TransactionEventListener listener : transactionEventListeners) {
|
||||
@@ -423,7 +427,7 @@ public class TransactionManager {
|
||||
event.add(tableEvents);
|
||||
|
||||
PostCommitProcessing postCommit = new PostCommitProcessing(clusterManager, this, event);
|
||||
postCommit.notifyLocalCache();
|
||||
postCommit.notifyLocalCache(viewInvalidation);
|
||||
backgroundExecutor.execute(postCommit.backgroundNotify());
|
||||
}
|
||||
|
||||
@@ -478,4 +482,13 @@ public class TransactionManager {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate the query caches for entities based on views.
|
||||
*/
|
||||
public void processViewInvalidation(Set<String> viewInvalidation) {
|
||||
if (!viewInvalidation.isEmpty()) {
|
||||
beanDescriptorManager.processViewInvalidation(viewInvalidation);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user