public class TestBatchLazyWithDeleted extends BaseTestCase {
@Test
public void testOnDeleted() {
UUOne oneA = new UUOne();
oneA.setName("oneA");
UUOne oneB = new UUOne();
oneB.setName("oneB");
UUTwo two = new UUTwo();
two.setName("two-bld-A");
two.setMaster(oneA);
UUTwo twoB = new UUTwo();
twoB.setName("two-bld-B");
twoB.setMaster(oneA);
UUTwo twoC = new UUTwo();
twoC.setName("two-bld-C");
twoC.setMaster(oneB);
Ebean.save(oneA);
Ebean.save(oneB);
Ebean.save(two);
Ebean.save(twoB);
Ebean.save(twoC);
List<UUTwo> list = Ebean.find(UUTwo.class)
.fetch("master", new FetchConfig().lazy(5))
.where().startsWith("name", "two-bld-")
.order("name")
.findList();
// delete a bean that will be batch lazy loaded but
// is NOT the bean that will invoke the lazy loading
// (in this case it is the second bean in the list).
int deletedCount = Ebean.delete(UUOne.class, oneB.getId());
Assert.assertEquals(1, deletedCount);
for (UUTwo u : list) {
u.getMaster();
//BeanState beanState = Ebean.getBeanState(master);