Examples of FetchConfig


Examples of com.avaje.ebean.FetchConfig

      RawSql rawSql = new RawSql(resultSet, "id", "name", "billingAddress.id");
     
      List<Customer> list = Ebean.find(Customer.class)
        .setRawSql(rawSql)
        // also test a secondary query join
        .fetch("billingAddress", new FetchConfig().query())
        .findList();

      for (Customer customer : list) {
        System.out.println("id:"+customer.getId()+" name:"+customer.getName()+" billingAddress:"+customer.getBillingAddress());
      }
View Full Code Here

Examples of com.avaje.ebean.FetchConfig

        .columnMapping("c.name", "order.customer.name")
        // .columnMapping("sum(d.order_qty*d.unit_price)", "totalAmount")
        .create();

    List<OrderAggregate> list2 = Ebean.find(OrderAggregate.class).setRawSql(rawSql)
        .fetch("order", new FetchConfig().query())
        .fetch("order.details", new FetchConfig().query())
        .where().gt("order.id", 2)
        .having().gt("totalAmount", 10)
        .filterMany("order.details").gt("unitPrice", 2d)
        .findList();

View Full Code Here

Examples of com.avaje.ebean.FetchConfig

  public void test() {

    ResetBasicData.reset();

    Query<OrderAggregate> q = Ebean.createNamedQuery(OrderAggregate.class, "total.amount");
    q.fetch("order", new FetchConfig().query());

    q.findList();
  }
View Full Code Here

Examples of com.avaje.ebean.FetchConfig

    Query<Customer> query = Ebean.find(Customer.class);
    query.setRawSql(rawSql);
    query.where().ilike("name", "r%");

    query.fetch("contacts", new FetchConfig().query());
    query.filterMany("contacts").gt("lastName", "b");

    List<Customer> list = query.findList();
    Assert.assertNotNull(list);
  }
View Full Code Here

Examples of com.avaje.ebean.FetchConfig

        // don't need this when using column alias
        // .columnMapping("sum(d.order_qty*d.unit_price)", "totalAmount")
        .create();

    Query<OrderAggregate> query = Ebean.find(OrderAggregate.class);
    query.setRawSql(rawSql).fetch("order", "status,orderDate", new FetchConfig().query())
        .fetch("order.customer", "name").where().gt("order.id", 0).having().gt("totalAmount", 20)
        .order().desc("totalAmount").setMaxRows(10);

    List<OrderAggregate> list = query.findList();
    Assert.assertNotNull(list);
View Full Code Here

Examples of com.avaje.ebean.FetchConfig

    Query<Customer> query = Ebean.find(Customer.class);
    query.setRawSql(rawSql);
    query.where().ilike("name", "r%");

    query.fetch("contacts", new FetchConfig().query());
    query.filterMany("contacts").gt("lastName", "b");

    List<Customer> list = query.findList();
    Assert.assertNotNull(list);
  }
View Full Code Here

Examples of com.avaje.ebean.FetchConfig

    ResetBasicData.reset();

    // This will use 3 SQL queries to build this object graph
    List<Order> l0 = Ebean.find(Order.class).select("status, shipDate")

    .fetch("details", "orderQty, unitPrice", new FetchConfig().query())
        .fetch("details.product", "sku, name")

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

Examples of com.avaje.ebean.FetchConfig

  public void test() {

    ResetBasicData.reset();

    List<Order> list = Ebean.find(Order.class)
        .fetch("customer", new FetchConfig().queryFirst(3).lazy(2))
        //.fetch("orders.details", new FetchConfig().query())
        //.fetch("orders.shipments", new FetchConfig().query())
        .findList();
   
    for (Order order : list) {
View Full Code Here

Examples of com.avaje.ebean.FetchConfig

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

Examples of com.avaje.ebean.FetchConfig

    ResetBasicData.reset();

    Query<Order> query = Ebean.find(Order.class)
        .select("status")
        .fetch("customer", "name, status", new FetchConfig().query())
        .fetch("customer.contacts")
        .fetch("details", new FetchConfig().query())
        .where().eq("status", Order.Status.NEW)
        .query();

//  .fetch("customer", "+query name, status")
//  .fetch("details", "+query(10)")
View Full Code Here
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.