mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
41 lines
1.1 KiB
Java
41 lines
1.1 KiB
Java
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<Order> query = Ebean.find(Order.class).select("status")
|
|
.fetch("customer", "+lazy(10) name, status").fetch("customer.contacts");
|
|
|
|
List<Order> 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);
|
|
}
|
|
|
|
}
|