package com.avaje.tests.batchload; import java.util.List; import org.junit.Assert; import org.junit.Test; import com.avaje.ebean.BaseTestCase; import com.avaje.ebean.Ebean; import com.avaje.ebean.Query; import com.avaje.tests.model.basic.Address; import com.avaje.tests.model.basic.Customer; import com.avaje.tests.model.basic.Order; import com.avaje.tests.model.basic.ResetBasicData; public class TestLazyJoin extends BaseTestCase { @Test public void testLazyOnNonLoaded() { ResetBasicData.reset(); Query query = Ebean.find(Order.class).select("status") .fetch("customer", "+lazy(10) name, status").fetch("customer.contacts"); List list = query.findList(); Order order = list.get(0); Customer customer = order.getCustomer(); // this invokes lazy loading on a property that is // not one of the selected ones (name, status) ... and // therefore the lazy load query selects all properties // in the customer (not just name and status) Address billingAddress = customer.getBillingAddress(); Assert.assertNotNull(billingAddress); } }