Package com.avaje.tests.model.basic

Examples of com.avaje.tests.model.basic.UUTwo


    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);
View Full Code Here


public class TestUuidInsertMasterDetail extends BaseTestCase {

  @Test
  public void testInsert() {

    UUTwo two = new UUTwo();
    two.setName("something");

    ArrayList<UUTwo> list = new ArrayList<UUTwo>();
    list.add(two);

    UUOne one = new UUOne();
    one.setName("some one");
    one.setComments(list);

    Ebean.save(one);

    UUOne oneB = Ebean.find(UUOne.class, one.getId());

    UUTwo twoB = new UUTwo();
    twoB.setName("another something");
    oneB.getComments().add(twoB);

    Ebean.save(oneB);
  }
View Full Code Here

    Ebean.save(oneB);
  }

  public void testNullFK() {

    UUTwo two = new UUTwo();
    two.setName("something");
    Ebean.save(two);
  }
View Full Code Here

    UUOne one = new UUOne();
    one.setName("oneName");

    Ebean.save(one);

    UUTwo two = new UUTwo();
    two.setMaster(one);
    two.setName("twoName");
   
    Ebean.save(two);
   
    UUTwo twoX = Ebean.find(UUTwo.class, two.getId());
   
    JsonContext jsonContext = Ebean.json();
   
    JsonWriteOptions writeOptions = JsonWriteOptions.parsePath("(id,name,master(*))");
    String jsonString = jsonContext.toJson(twoX, writeOptions);
   
    System.out.println(jsonString);
    jsonString = jsonString.replace("twoName", "twoNameModified");
    jsonString = jsonString.replace("oneName", "oneNameModified");
   
   
    UUTwo two2 = jsonContext.toBean(UUTwo.class, jsonString);
   
    Assert.assertEquals(twoX.getId(), two2.getId());
    Assert.assertEquals("twoNameModified", two2.getName());
    Assert.assertEquals("oneNameModified", two2.getMaster().getName());

    // The update below cascades to also save "master" and that fails
    // as it thinks it should INSERT master rather than UPDATE master
   
    Ebean.update(two2);


    // confirm the properties where updated as expected
    UUTwo twoConfirm = Ebean.find(UUTwo.class, two.getId());

    Assert.assertEquals("twoNameModified", twoConfirm.getName());
    Assert.assertEquals("oneNameModified", twoConfirm.getMaster().getName());
       
  }
View Full Code Here

   
    // setup
    UUOne master1 = new UUOne();
    master1.setName("testDisjOuter_1_name");

    UUTwo detail1 = new UUTwo();
    detail1.setMaster(master1);
    detail1.setName("testDisjOuter_CHILD_1");

    UUOne master2 = new UUOne();
    master2.setName("testDisjOuter_2_name");

    Ebean.save(master1);
View Full Code Here

TOP

Related Classes of com.avaje.tests.model.basic.UUTwo

Copyright © 2018 www.massapicom. 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.