Package com.avaje.tests.basic

Source Code of com.avaje.tests.basic.TestLazyLoadEmptyOneToMany

package com.avaje.tests.basic;

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.tests.model.basic.Contact;
import com.avaje.tests.model.basic.Customer;
import com.avaje.tests.model.basic.ResetBasicData;

public class TestLazyLoadEmptyOneToMany extends BaseTestCase {

  @Test
  public void test() {

    ResetBasicData.reset();

    Customer c = new Customer();
    c.setName("testll");

    Ebean.save(c);

    Customer c1 = Ebean.find(Customer.class)
        .setAutofetch(false)
        .select("id")
        .fetch("contacts", "id")
        .where().idEq(c.getId())
        .findUnique();

    List<Contact> contacts = c1.getContacts();
    int sz = contacts.size();

    Assert.assertTrue(sz == 0);
  }
}
TOP

Related Classes of com.avaje.tests.basic.TestLazyLoadEmptyOneToMany

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.