diff --git a/src/main/java/com/avaje/ebean/Ebean.java b/src/main/java/com/avaje/ebean/Ebean.java
index 1255f3a2c..fb67b88c0 100644
--- a/src/main/java/com/avaje/ebean/Ebean.java
+++ b/src/main/java/com/avaje/ebean/Ebean.java
@@ -1484,29 +1484,6 @@ public final class Ebean {
return serverMgr.getDefaultServer().getBackgroundExecutor();
}
- /**
- * Run the cache warming queries on all bean types that have one defined for
- * the default/primary EbeanServer.
- *
- * A cache warming query can be defined via {@link CacheStrategy}.
- *
- */
- public static void runCacheWarming() {
- serverMgr.getDefaultServer().runCacheWarming();
- }
-
- /**
- * Run the cache warming query for a specific bean type for the
- * default/primary EbeanServer.
- *
- * A cache warming query can be defined via {@link CacheStrategy}.
- *
- */
- public static void runCacheWarming(Class> beanType) {
-
- serverMgr.getDefaultServer().runCacheWarming(beanType);
- }
-
/**
* Return the JsonContext for reading/writing JSON.
*/
diff --git a/src/main/java/com/avaje/ebean/EbeanServer.java b/src/main/java/com/avaje/ebean/EbeanServer.java
index 047568a3e..ed40ffb05 100644
--- a/src/main/java/com/avaje/ebean/EbeanServer.java
+++ b/src/main/java/com/avaje/ebean/EbeanServer.java
@@ -1846,22 +1846,6 @@ public interface EbeanServer {
*/
BackgroundExecutor getBackgroundExecutor();
- /**
- * Run the cache warming queries on all bean types that have one defined.
- *
- * A cache warming query can be defined via {@link CacheStrategy}.
- *
- */
- void runCacheWarming();
-
- /**
- * Run the cache warming query for a specific bean type.
- *
- * A cache warming query can be defined via {@link CacheStrategy}.
- *
- */
- void runCacheWarming(Class> beanType);
-
/**
* Return the JsonContext for reading/writing JSON.
*
diff --git a/src/main/java/com/avaje/ebean/annotation/CacheStrategy.java b/src/main/java/com/avaje/ebean/annotation/CacheStrategy.java
index 765bc2d80..ded62462b 100644
--- a/src/main/java/com/avaje/ebean/annotation/CacheStrategy.java
+++ b/src/main/java/com/avaje/ebean/annotation/CacheStrategy.java
@@ -42,17 +42,4 @@ public @interface CacheStrategy {
*/
boolean readOnly() default false;
- /**
- * Specify a query that can be used to warm the cache.
- *
- * All the beans fetched by this query will be loaded into the bean cache and
- * the query itself will be loaded into the query cache.
- *
- *
- * The warming query will typically be executed at startup time after a short
- * delay (defaults to a 30 seconds delay).
- *
- */
- String warmingQuery() default "";
-
}
diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/CacheOptions.java b/src/main/java/com/avaje/ebeaninternal/server/core/CacheOptions.java
index cb31f5c70..0ca7641aa 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/core/CacheOptions.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/core/CacheOptions.java
@@ -11,8 +11,6 @@ public class CacheOptions {
private String naturalKey;
- private String warmingQuery;
-
private int maxIdleSecs;
private long maxSecsToLive;
@@ -51,20 +49,6 @@ public class CacheOptions {
this.readOnly = readOnly;
}
- /**
- * Return the query used to warm the cache.
- */
- public String getWarmingQuery() {
- return warmingQuery;
- }
-
- /**
- * Set the cache warming query.
- */
- public void setWarmingQuery(String warmingQuery) {
- this.warmingQuery = warmingQuery;
- }
-
/**
* Return true if a natural key is set.
*/
diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java
index 750eccd9c..ffc80b7f9 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultContainer.java
@@ -1,6 +1,5 @@
package com.avaje.ebeaninternal.server.core;
-import com.avaje.ebean.EbeanServer;
import com.avaje.ebean.cache.ServerCacheFactory;
import com.avaje.ebean.cache.ServerCacheManager;
import com.avaje.ebean.cache.ServerCacheOptions;
@@ -32,8 +31,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.ServiceLoader;
-import java.util.Timer;
-import java.util.TimerTask;
/**
* Default Server side implementation of ServerFactory.
@@ -138,13 +135,6 @@ public class DefaultContainer implements SpiContainer {
// register the server once it has been created
clusterManager.registerServer(server);
}
-
- // warm the cache in 30 seconds
- long sleepMillis = 1000 * serverConfig.getCacheWarmingDelay();
- if (sleepMillis > 0) {
- Timer timer = new Timer("EbeanCacheWarmer", true);
- timer.schedule(new CacheWarmer(server, timer), sleepMillis);
- }
}
// start any services after registering with clusterManager
@@ -364,21 +354,4 @@ public class DefaultContainer implements SpiContainer {
}
}
- private static class CacheWarmer extends TimerTask {
-
- private final EbeanServer server;
-
- private final Timer timer;
-
- CacheWarmer(EbeanServer server, Timer timer) {
- this.server = server;
- this.timer = timer;
- }
-
- public void run() {
- server.runCacheWarming();
- timer.cancel();
- }
-
- }
}
diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java
index cfb4220b5..1a10db6e9 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java
@@ -421,26 +421,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
return null;
}
- /**
- * Run the cache warming queries on all beans that have them defined.
- */
- public void runCacheWarming() {
- List> descList = beanDescriptorManager.getBeanDescriptorList();
- for (int i = 0; i < descList.size(); i++) {
- descList.get(i).runCacheWarming();
- }
- }
-
- public void runCacheWarming(Class> beanType) {
- BeanDescriptor> desc = beanDescriptorManager.getBeanDescriptor(beanType);
- if (desc == null) {
- String msg = "Is " + beanType + " an entity? Could not find a BeanDescriptor";
- throw new PersistenceException(msg);
- } else {
- desc.runCacheWarming();
- }
- }
-
/**
* Compile a query. Only valid for ORM queries.
*/
diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java
index 641bd55d5..a45cf92b6 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptor.java
@@ -895,13 +895,6 @@ public class BeanDescriptor implements MetaBeanInfo, BeanType {
return owner.getEncryptKey(tableName, columnName);
}
- /**
- * Execute the warming cache query (if defined) and load the cache.
- */
- public void runCacheWarming() {
- cacheHelp.runCacheWarming(ebeanServer);
- }
-
/**
* Return true if this bean type has a default select clause that is not
* simply select all properties.
diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java
index 9bc143455..759d0eb64 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/BeanDescriptorCacheHelp.java
@@ -1,7 +1,5 @@
package com.avaje.ebeaninternal.server.deploy;
-import com.avaje.ebean.EbeanServer;
-import com.avaje.ebean.Query;
import com.avaje.ebean.bean.BeanCollection;
import com.avaje.ebean.bean.EntityBean;
import com.avaje.ebean.bean.EntityBeanIntercept;
@@ -88,26 +86,6 @@ final class BeanDescriptorCacheHelp {
}
}
- /**
- * Execute the warming cache query (if defined) and load the cache.
- */
- public void runCacheWarming(EbeanServer ebeanServer) {
- if (cacheOptions == null) {
- return;
- }
- String warmingQuery = cacheOptions.getWarmingQuery();
- if (warmingQuery != null && warmingQuery.trim().length() > 0) {
- Query> query = ebeanServer.createQuery(beanType, warmingQuery);
- query.setUseCache(true);
- query.setReadOnly(true);
- query.setLoadBeanCache(true);
- List> list = query.findList();
- if (beanLog.isInfoEnabled()) {
- beanLog.info("Loaded {} cache with [{}] beans", cacheName, list.size());
- }
- }
- }
-
public void setUseCache(boolean useCache) {
if (useCache) {
getBeanCache();
diff --git a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationClass.java b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationClass.java
index f7421a77b..eda36ef56 100644
--- a/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationClass.java
+++ b/src/main/java/com/avaje/ebeaninternal/server/deploy/parse/AnnotationClass.java
@@ -218,7 +218,6 @@ public class AnnotationClass extends AnnotationParser {
if (cacheStrategy != null) {
cacheOptions.setUseCache(cacheStrategy.useBeanCache());
cacheOptions.setReadOnly(cacheStrategy.readOnly());
- cacheOptions.setWarmingQuery(cacheStrategy.warmingQuery());
if (cacheStrategy.naturalKey().length() > 0) {
String propName = cacheStrategy.naturalKey().trim();
DeployBeanProperty beanProperty = descriptor.getBeanProperty(propName);
diff --git a/src/test/java/com/avaje/ebean/BaseTestCase.java b/src/test/java/com/avaje/ebean/BaseTestCase.java
index 1a1f3875b..c8b31599f 100644
--- a/src/test/java/com/avaje/ebean/BaseTestCase.java
+++ b/src/test/java/com/avaje/ebean/BaseTestCase.java
@@ -2,6 +2,7 @@ package com.avaje.ebean;
import com.avaje.ebeaninternal.api.SpiEbeanServer;
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
+import com.avaje.tests.model.basic.Country;
import org.avaje.agentloader.AgentLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,4 +54,11 @@ public class BaseTestCase {
protected EbeanServer server() {
return Ebean.getDefaultServer();
}
+
+ protected void loadCountryCache() {
+
+ Ebean.find(Country.class)
+ .setLoadBeanCache(true)
+ .findList();
+ }
}
diff --git a/src/test/java/com/avaje/ebeaninternal/api/TDSpiEbeanServer.java b/src/test/java/com/avaje/ebeaninternal/api/TDSpiEbeanServer.java
index a26f1bf06..7fea06173 100644
--- a/src/test/java/com/avaje/ebeaninternal/api/TDSpiEbeanServer.java
+++ b/src/test/java/com/avaje/ebeaninternal/api/TDSpiEbeanServer.java
@@ -729,16 +729,6 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
return null;
}
- @Override
- public void runCacheWarming() {
-
- }
-
- @Override
- public void runCacheWarming(Class> beanType) {
-
- }
-
@Override
public JsonContext json() {
return null;
diff --git a/src/test/java/com/avaje/tests/cache/TestCacheBasic.java b/src/test/java/com/avaje/tests/cache/TestCacheBasic.java
index c97810490..f804cf9a3 100644
--- a/src/test/java/com/avaje/tests/cache/TestCacheBasic.java
+++ b/src/test/java/com/avaje/tests/cache/TestCacheBasic.java
@@ -20,7 +20,7 @@ public class TestCacheBasic extends BaseTestCase {
Ebean.getServerCacheManager().clear(Country.class);
ServerCache countryCache = Ebean.getServerCacheManager().getBeanCache(Country.class);
- Ebean.runCacheWarming(Country.class);
+ loadCountryCache();
Assert.assertTrue(countryCache.size() > 0);
// reset the statistics
diff --git a/src/test/java/com/avaje/tests/cache/TestExternalNotification.java b/src/test/java/com/avaje/tests/cache/TestExternalNotification.java
index af2814e0f..4ea3cfb47 100644
--- a/src/test/java/com/avaje/tests/cache/TestExternalNotification.java
+++ b/src/test/java/com/avaje/tests/cache/TestExternalNotification.java
@@ -1,8 +1,5 @@
package com.avaje.tests.cache;
-import org.junit.Assert;
-import org.junit.Test;
-
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.SqlUpdate;
@@ -10,6 +7,10 @@ import com.avaje.ebean.cache.ServerCache;
import com.avaje.ebean.cache.ServerCacheManager;
import com.avaje.tests.model.basic.Country;
import com.avaje.tests.model.basic.ResetBasicData;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
public class TestExternalNotification extends BaseTestCase {
@@ -18,43 +19,43 @@ public class TestExternalNotification extends BaseTestCase {
ResetBasicData.reset();
- Ebean.runCacheWarming(Country.class);
+ loadCountryCache();
ServerCache countryCache = Ebean.getServerCacheManager().getBeanCache(Country.class);
- Assert.assertTrue(countryCache.size() > 0);
+ assertTrue(countryCache.size() > 0);
// inserts don't remove from bean cache
Ebean.externalModification("o_country", true, false, false);
- Assert.assertTrue(countryCache.size() > 0);
+ assertTrue(countryCache.size() > 0);
// updates flush cache
Ebean.externalModification("o_country", false, true, false);
- Assert.assertEquals(0, countryCache.size());
+ assertEquals(0, countryCache.size());
- Ebean.runCacheWarming(Country.class);
- Assert.assertTrue(countryCache.size() > 0);
+ loadCountryCache();
+ assertTrue(countryCache.size() > 0);
// deletes flush cache
Ebean.externalModification("o_country", false, false, true);
- Assert.assertEquals(0, countryCache.size());
+ assertEquals(0, countryCache.size());
- Ebean.runCacheWarming(Country.class);
- Assert.assertTrue(countryCache.size() > 0);
+ loadCountryCache();
+ assertTrue(countryCache.size() > 0);
ServerCacheManager serverCacheManager = Ebean.getServerCacheManager();
serverCacheManager.clearAll();
- Assert.assertEquals(0, countryCache.size());
+ assertEquals(0, countryCache.size());
- Ebean.runCacheWarming(Country.class);
- Assert.assertTrue(countryCache.size() > 0);
+ loadCountryCache();
+ assertTrue(countryCache.size() > 0);
Ebean.getServerCacheManager().clear(Country.class);
- Assert.assertEquals(0, countryCache.size());
+ assertEquals(0, countryCache.size());
- Ebean.runCacheWarming(Country.class);
+ loadCountryCache();
int cacheSize = countryCache.size();
- Assert.assertTrue("cacheSize: " + cacheSize, cacheSize > 0);
+ assertTrue("cacheSize: " + cacheSize, cacheSize > 0);
SqlUpdate sqlUpdate = Ebean
.createSqlUpdate("update o_country set name = :name where code = :code");
@@ -63,13 +64,13 @@ public class TestExternalNotification extends BaseTestCase {
// this should just clear the entire country cache
int rows = sqlUpdate.execute();
- Assert.assertEquals(1, rows);
- Assert.assertEquals(0, countryCache.size());
+ assertEquals(1, rows);
+ assertEquals(0, countryCache.size());
// set it back...
sqlUpdate.setParameter("name", "New Zealand");
sqlUpdate.setParameter("code", "NZ");
rows = sqlUpdate.execute();
- Assert.assertEquals(1, rows);
+ assertEquals(1, rows);
}
}
diff --git a/src/test/java/com/avaje/tests/model/basic/Article.java b/src/test/java/com/avaje/tests/model/basic/Article.java
index 759afb8c0..27888a897 100644
--- a/src/test/java/com/avaje/tests/model/basic/Article.java
+++ b/src/test/java/com/avaje/tests/model/basic/Article.java
@@ -10,7 +10,7 @@ import javax.persistence.OneToMany;
import com.avaje.ebean.annotation.CacheStrategy;
-@CacheStrategy(useBeanCache=true, warmingQuery="find article join sections")
+@CacheStrategy
@Entity
public class Article extends BasicDomain {
diff --git a/src/test/java/com/avaje/tests/model/basic/Country.java b/src/test/java/com/avaje/tests/model/basic/Country.java
index 388dba57a..177df1636 100644
--- a/src/test/java/com/avaje/tests/model/basic/Country.java
+++ b/src/test/java/com/avaje/tests/model/basic/Country.java
@@ -18,7 +18,7 @@ import javax.validation.constraints.Size;
@DocStore
@ReadAudit
@ChangeLog(inserts = ChangeLogInsertMode.INCLUDE)
-@CacheStrategy(readOnly = true, warmingQuery = "order by name")
+@CacheStrategy(readOnly = true)
@CacheTuning(maxSize = 500)
@Entity
@Table(name = "o_country")
diff --git a/src/test/java/com/avaje/tests/model/basic/Product.java b/src/test/java/com/avaje/tests/model/basic/Product.java
index 711956ab3..b471420de 100644
--- a/src/test/java/com/avaje/tests/model/basic/Product.java
+++ b/src/test/java/com/avaje/tests/model/basic/Product.java
@@ -17,7 +17,7 @@ import com.avaje.ebean.annotation.DocStore;
* Product entity bean.
*/
@DocStore
-@CacheStrategy(warmingQuery = "order by name")
+@CacheStrategy
@Entity
@Table(name = "o_product")
public class Product implements Serializable {
diff --git a/src/test/java/com/avaje/tests/query/TestQueryFindReadOnly.java b/src/test/java/com/avaje/tests/query/TestQueryFindReadOnly.java
index d099d54db..451d73024 100644
--- a/src/test/java/com/avaje/tests/query/TestQueryFindReadOnly.java
+++ b/src/test/java/com/avaje/tests/query/TestQueryFindReadOnly.java
@@ -32,7 +32,7 @@ public class TestQueryFindReadOnly extends BaseTestCase {
Section s2 = ar1sections.get(0);
Assert.assertTrue("readonly cascading", Ebean.getBeanState(s2).isReadOnly());
- Ebean.runCacheWarming(Article.class);
+ Ebean.find(Article.class).setLoadBeanCache(true).findList();
Article ar0 = Ebean.find(Article.class, a0.getId());