Package com.avaje.ebean

Examples of com.avaje.ebean.RawSql$Sql


  private SqlLimitResponse buildSql(String selectClause, OrmQueryRequest<?> request, CQueryPredicates predicates, SqlTree select) {

    SpiQuery<?> query = request.getQuery();

    RawSql rawSql = query.getRawSql();
    if (rawSql != null) {
      return rawSqlHandler.buildSql(request, predicates, rawSql.getSql());
    }

    BeanPropertyAssocMany<?> manyProp = select.getManyProperty();

    boolean useSqlLimiter = false;
View Full Code Here


        Dnode cm = columnMappings.get(j);
        String column = cm.getAttribute("column");
        String property = cm.getAttribute("property");
        rawSqlBuilder.columnMapping(column, property);
      }
      RawSql rawSql = rawSqlBuilder.create();

      DeployNamedQuery namedQuery = new DeployNamedQuery(name, rawSql);
      deployDesc.add(namedQuery);
    }
  }
View Full Code Here

      pstmt = txn.getConnection().prepareStatement("select id, name, billing_address_id from o_customer");
     
      // ResultSet will be closed by Ebean
      ResultSet resultSet = pstmt.executeQuery();
     
      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())
View Full Code Here

  @Test
  public void test() {

    ResetBasicData.reset();

    RawSql rawSql = RawSqlBuilder
        .parse("select r.id, r.name from o_customer r where r.id >= ? and r.name like ?")
        .columnMapping("r.id", "id").columnMapping("r.name", "name").create();

    Query<Customer> query = Ebean.find(Customer.class);
    query.setRawSql(rawSql);
View Full Code Here

  @Test
  public void test_unparsed() {

    ResetBasicData.reset();

    RawSql rawSql = RawSqlBuilder
        .unparsed("select r.id, r.name from o_customer r where r.id >= ? and r.name like ?")
        .columnMapping("r.id", "id")
        .columnMapping("r.name", "name").create();

    Query<Customer> query = Ebean.find(Customer.class);
View Full Code Here

        + " from o_order o"
        + " join o_customer c on c.id = o.kcustomer_id "
        + " join o_order_detail d on d.order_id = o.id "
        + " group by order_id, o.status, c.id, c.name ";

    RawSql rawSql = RawSqlBuilder.parse(sql).columnMapping("order_id", "order.id")
        .columnMapping("o.status", "order.status").columnMapping("c.id", "order.customer.id")
        .columnMapping("c.name", "order.customer.name")
        // .columnMapping("sum(d.order_qty*d.unit_price)", "totalAmount")
        .create();

View Full Code Here

   
      ResetBasicData.reset();
     
     
      // try valid query where spaces in the formula ...
      RawSql rawSql =
          RawSqlBuilder
              .parse("select r.id, r.name || 'hello' as name from o_customer r ")
              .create();
                 
      Query<Customer> query = Ebean.find(Customer.class);
View Full Code Here

  @Test
  public void test() {

    ResetBasicData.reset();

    RawSql rawSql = RawSqlBuilder
        .parse(
            "select c.customer_id, count(*) as totalContacts from contact c  group by c.customer_id")
        .columnMapping("c.customer_id", "customer.id").create();

    Query<CustomerAggregate> query = Ebean.find(CustomerAggregate.class);
View Full Code Here

        + " from o_order o"
        + " join o_customer c on c.id = o.kcustomer_id "
        + " join o_order_detail d on d.order_id = o.id "
        + " group by order_id, o.status, c.id, c.name ";

    RawSql rawSql = RawSqlBuilder.parse(sql).columnMapping("order_id", "order.id")
        .columnMapping("o.status", "order.status").columnMapping("c.id", "order.customer.id")
        .columnMapping("c.name", "order.customer.name")
        // .columnMapping("sum(d.order_qty*d.unit_price)", "totalAmount")
        .create();

View Full Code Here

  @Test
  public void test() {

    ResetBasicData.reset();

    RawSql rawSql0 = RawSqlBuilder.parse(" select  distinct  r.id, r.name from o_customer r ")
        .create();

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

    RawSql rawSql = RawSqlBuilder.parse(" select  distinct  r.id, r.name from o_customer r ")
        .columnMapping("r.id", "id").columnMapping("r.name", "name").create();

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

TOP

Related Classes of com.avaje.ebean.RawSql$Sql

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.