#360 ENH: Add query setDisableLazyLoading(true) ... for use when graph serialised via external library (and you don't want lazy loading to fire)

This commit is contained in:
Robin Bygrave
2015-07-29 20:31:25 +12:00
parent 59d009bc94
commit 3d4bd15dac
14 changed files with 239 additions and 39 deletions
@@ -0,0 +1,40 @@
package com.avaje.ebeaninternal.server.querydefn;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.FetchConfig;
import com.avaje.ebeaninternal.api.HashQueryPlan;
import com.avaje.ebeaninternal.api.HashQueryPlanBuilder;
import com.avaje.ebeaninternal.api.SpiQuery;
import com.avaje.tests.model.basic.Order;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class DefaultOrmQueryTest {
@Test
public void testQueryAutofetchHash() throws Exception {
SpiQuery<?> query1 = (SpiQuery<?>)Ebean.find(Order.class)
.select("status, shipDate")
.fetch("details", "orderQty, unitPrice", new FetchConfig().query())
.fetch("details.product", "sku, name");
HashQueryPlanBuilder b1 = new HashQueryPlanBuilder();
query1.queryAutofetchHash(b1);
HashQueryPlan hash1 = b1.build();
SpiQuery<?> query2 = (SpiQuery<?>)Ebean.find(Order.class)
.select("status, shipDate")
.fetch("details", "orderQty, unitPrice")
.fetch("details.product", "sku, name");
HashQueryPlanBuilder b2 = new HashQueryPlanBuilder();
query2.queryAutofetchHash(b2);
HashQueryPlan hash2 = b2.build();
assertThat(hash1).isNotEqualTo(hash2);
}
}