mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
#2748 - Fix such that .setLoadBeanCache(false) ... sets CacheMode.OFF
This commit is contained in:
1 parent
a5e3b9e68a
commit
9252e72581
4 files changed
+17
-4
No files matched your search
@@ -1579,10 +1579,11 @@ public interface Query<T> extends CancelableQuery {
|
|||||||
Query<T> setReadOnly(boolean readOnly);
|
Query<T> setReadOnly(boolean readOnly);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will be deprecated - migrate to use setBeanCacheMode(CacheMode.RECACHE).
|
* Deprecated - migrate to use setBeanCacheMode(CacheMode.PUT) or other CacheMode.
|
||||||
* <p>
|
* <p>
|
||||||
* When set to true all the beans from this query are loaded into the bean cache.
|
* When set to true all the beans from this query are loaded into the bean cache.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
Query<T> setLoadBeanCache(boolean loadBeanCache);
|
Query<T> setLoadBeanCache(boolean loadBeanCache);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1270,7 +1270,7 @@ public class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Query<T> setLoadBeanCache(boolean loadBeanCache) {
|
public final Query<T> setLoadBeanCache(boolean loadBeanCache) {
|
||||||
this.useBeanCache = CacheMode.PUT;
|
this.useBeanCache = loadBeanCache ? CacheMode.PUT : CacheMode.OFF;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -852,9 +852,11 @@ public abstract class TQRootBean<T, R> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When set to true all the beans from this query are loaded into the bean
|
* Deprecated migrate to setBeanCacheMode() or setUseCache().
|
||||||
* cache.
|
* <p>
|
||||||
|
* When set to true all the beans from this query are loaded into the bean cache.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public R setLoadBeanCache(boolean loadBeanCache) {
|
public R setLoadBeanCache(boolean loadBeanCache) {
|
||||||
query.setLoadBeanCache(loadBeanCache);
|
query.setLoadBeanCache(loadBeanCache);
|
||||||
return root;
|
return root;
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package org.tests.basic;
|
package org.tests.basic;
|
||||||
|
|
||||||
|
import io.ebean.Query;
|
||||||
import io.ebean.xtest.BaseTestCase;
|
import io.ebean.xtest.BaseTestCase;
|
||||||
import io.ebean.DB;
|
import io.ebean.DB;
|
||||||
import io.ebean.test.LoggedSql;
|
import io.ebean.test.LoggedSql;
|
||||||
|
import io.ebeaninternal.api.SpiQuery;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.tests.model.basic.Country;
|
import org.tests.model.basic.Country;
|
||||||
import org.tests.model.basic.Customer;
|
import org.tests.model.basic.Customer;
|
||||||
@@ -16,6 +18,14 @@ import static org.junit.jupiter.api.Assertions.assertSame;
|
|||||||
|
|
||||||
class TestLoadBeanCache extends BaseTestCase {
|
class TestLoadBeanCache extends BaseTestCase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void loadBeanCache_false() {
|
||||||
|
Query<Country> query = DB.find(Country.class).setLoadBeanCache(false);
|
||||||
|
|
||||||
|
SpiQuery<?> spiQuery = (SpiQuery<?>) query;
|
||||||
|
assertThat(spiQuery.isBeanCachePut()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testLoad() {
|
void testLoad() {
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user