mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Add more assertions for nested one-to-many fetch
This commit is contained in:
@@ -11,6 +11,7 @@ import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -54,6 +55,17 @@ public class TestQueryJoinManyNonRoot extends BaseTestCase {
|
||||
assertTrue(sql.contains("join o_customer t1 on t1.id "));
|
||||
assertTrue(sql.contains("left join contact t2 on"));
|
||||
|
||||
Map<Integer, Order> ordersById = Ebean.find(Order.class).setMapKey("id").where().gt("id", 0).query().findMap();
|
||||
for (Order o: list) {
|
||||
int withoutFetch = ordersById.get(o.getId()).getCustomer().getContacts().size();
|
||||
int withFetch = o.getCustomer().getContacts().size();
|
||||
assertEquals(String.format("order.customer.contacts for order %d did not match. " +
|
||||
"Items without fetch: %d, with fetch: %d", o.getId(), withoutFetch, withFetch),
|
||||
withoutFetch,
|
||||
withFetch);
|
||||
}
|
||||
|
||||
|
||||
// select t0.id c0, t0.status c1, t0.order_date c2, t0.ship_date c3, t1.name c4, t0.cretime c5, t0.updtime c6,
|
||||
// t1.id c7, t1.status c8, t1.name c9, t1.smallnote c10, t1.anniversary c11, t1.cretime c12, t1.updtime c13, t1.billing_address_id c14, t1.shipping_address_id c15,
|
||||
// t2.id c16, t2.first_name c17, t2.last_name c18, t2.phone c19, t2.mobile c20, t2.email c21, t2.cretime c22, t2.updtime c23, t2.customer_id c24, t2.group_id c25
|
||||
|
||||
Reference in New Issue
Block a user