Package com.avaje.tests.model.basic

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


    OGearBox gearBox = new OGearBox();
    gearBox.setBoxDesc("6 speed manual");
    gearBox.setSize(6);

    OCar car = new OCar();
    car.setVin("xx4534");
    car.setName("test car");
    car.setEngine(engine);

    Ebean.beginTransaction();
    try {
      Ebean.save(gearBox);
      Ebean.save(car);

      Assert.assertNotNull(car.getId());
      Assert.assertNotNull(engine.getEngineId());
      Assert.assertNotNull(gearBox.getId());

      Ebean.commitTransaction();

    } finally {
      Ebean.endTransaction();
    }

    OCar c2 = Ebean.find(OCar.class, car.getId());
    Assert.assertNotNull(c2);
    Assert.assertNotNull(c2.getEngine());
    // gearBox not assigned yet
    Assert.assertNull(c2.getGearBox());

    // ok, assign gearBox
    c2.setGearBox(gearBox);
    Ebean.save(c2);

    // now all should be there...
    OCar c3 = Ebean.find(OCar.class, car.getId());
    Assert.assertNotNull(c3);
    Assert.assertNotNull(c3.getEngine());
    Assert.assertNotNull(c3.getGearBox());

  }
View Full Code Here

TOP

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

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.