Package com.avaje.tests.model.basic

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


  private void output(List<OrderAggregate> list) {

    for (OrderAggregate oa : list) {
      Double totalAmount = oa.getTotalAmount();
      Order order = oa.getOrder();
      Integer id = order.getId();
      Status status = order.getStatus();
      System.out.println("Order: " + id + " " + status + " total:" + totalAmount);

      Customer c = order.getCustomer();
      System.out.println("   -> customer: " + c.getId() + " " + c.getName());

      // invoke lazy loading as this property
      // has not populated originally
      // order.getOrderDate();
View Full Code Here


  private void output(List<OrderAggregate> list) {

    for (OrderAggregate oa : list) {
      Double totalAmount = oa.getTotalAmount();
      Order order = oa.getOrder();
      Integer id = order.getId();
      Status status = order.getStatus();
      System.out.println("Order: " + id + " " + status + " total:" + totalAmount);

      Customer c = order.getCustomer();
      System.out.println("   -> customer: " + c.getId() + " " + c.getName());

      // invoke lazy loading as this property
      // has not populated originally
      // order.getOrderDate();
View Full Code Here

    List<OrderAggregate> list = query.findList();
    Assert.assertNotNull(list);

    for (OrderAggregate oa : list) {
      Double totalAmount = oa.getTotalAmount();
      Order order = oa.getOrder();
      Integer id = order.getId();
      System.out.println("Order: " + id + " total:" + totalAmount);
    }

  }
View Full Code Here

        .fetch("customer", "name", new FetchConfig().query(10))
        .fetch("customer.contacts", "firstName, lastName, mobile")
        .fetch("customer.shippingAddress", "line1, city").order().asc("id").findList();

    Order o0 = l0.get(0);
    Customer c0 = o0.getCustomer();
    List<Contact> contacts = c0.getContacts();
    Assert.assertTrue(contacts.size() > 0);

    // query 1) find order (status, shipDate)
    // query 2) find orderDetail (quantity, price) join product (sku, name)
    // where order.id in (?,? ...)
    // query 3) find customer (name) join contacts (*) join shippingAddress (*)
    // where id in (?,?,?,?,?)

    List<Order> orders = Ebean.find(Order.class)
    // .select("status")
        .fetch("customer", new FetchConfig().query(3).lazy(10)).order().asc("id").findList();
    // .join("customer.contacts");

    // List<Order> list = query.findList();

    Order order = orders.get(0);
    Customer customer = order.getCustomer();

    // this invokes lazy loading on a property that is
    // not one of the selected ones (name, status) ... and
    // therefore the lazy load query selects all properties
    // in the customer (not just name and status)
    Address billingAddress = customer.getBillingAddress();

    Assert.assertNotNull(billingAddress);

    List<Order> list = Ebean.find(Order.class).fetch("customer", "name", new FetchConfig().lazy(5))
        .fetch("customer.contacts", "contactName, phone, email").fetch("customer.shippingAddress")
        .where().eq("status", Order.Status.NEW).order().asc("id").findList();

    Order order2 = list.get(0);
    Customer customer2 = order2.getCustomer();
    // customer2.getStatus();
    String name = customer2.getName();
    Assert.assertNotNull(name);

    String q = "find order join customer (+query(1) +lazy(10) name, status) join customer.contacts ";
    Query<Order> query = Ebean.createQuery(Order.class, q);

    List<Order> list3 = query.findList();
    Order order3 = list3.get(0);
    String n3 = order3.getCustomer().getName();

    for (Order o3 : list3) {
      o3.getCustomer().getName();
    }

View Full Code Here

    // no orders or customers in the PC
    Assert.assertEquals(0, pc.size(Order.class));
    Assert.assertEquals(0, pc.size(Customer.class));

    Order order0 = null;
    try {

      EbeanServer server = Ebean.getServer(null);
      List<Order> list = server.find(Order.class).fetch("customer").fetch("details").findList();
View Full Code Here

  @Test
  public void test() {

    Customer c = new Customer();
    if (c instanceof EntityBean) {
      Order o = new Order();
      if (o instanceof EntityBean) {

        c.setId(1);

        o.setId(1);

        Assert.assertFalse(c.equals(o));
        Assert.assertFalse(c.equals(null));
        Assert.assertTrue(c.equals(c));
View Full Code Here

        .fetch("customer.contacts").where().lt("id", 3).query();

    List<Order> list = q.findList();

    for (int i = 0; i < list.size(); i++) {
      Order order = list.get(i);
      order.getOrderDate();
      order.getShipDate();
      // order.setShipDate(new Date(System.currentTimeMillis()));
      Customer customer = order.getCustomer();
      customer.getName();
      Address shippingAddress = customer.getShippingAddress();
      if (shippingAddress != null) {
        shippingAddress.getLine1();
        shippingAddress.getCity();
View Full Code Here

  @Test
  public void testSecQueryOneToMany() {

    ResetBasicData.reset();

    Order testOrder = ResetBasicData.createOrderCustAndOrder("testSecQry10");
    Integer custId = testOrder.getCustomer().getId();

     Query<Customer> query = Ebean.find(Customer.class)
         .select("name")
         .fetch("contacts", "+query")
         .setId(custId);
View Full Code Here

  @Test
  public void testQueries() {

    ResetBasicData.reset();

    Order order = Ebean.find(Order.class).select("totalAmount").setMaxRows(1).order("id")
        .findUnique();

    Assert.assertNotNull(order);

    Customer customer = order.getCustomer();
    Assert.assertNotNull(customer);
    Assert.assertNotNull(customer.getName());

    Address address = customer.getBillingAddress();
    Assert.assertNotNull(address);
View Full Code Here

  }

  public void testRaceCondition_Simple() throws Throwable {
    ResetBasicData.reset();

    Order order = Ebean.find(Order.class).select("totalAmount").setMaxRows(1).order("id")
        .findUnique();

    Assert.assertNotNull(order);

    final Customer customer = order.getCustomer();
    Assert.assertNotNull(customer);

    Assert.assertTrue(Ebean.getBeanState(customer).isReference());

    final Throwable throwables[] = new Throwable[2];
View Full Code Here

TOP

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

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.