Examples of DomainObject


Examples of org.apache.openjpa.persistence.query.DomainObject

       
        compare(jpql, c);
    }
   
    public void testIsEmpty() {
        DomainObject o = qb.createQueryDefinition(Order.class);
        o.where(o.get("lineItems").isEmpty());
       
       
        String jpql = "select o from Order o " +
                      " where o.lineItems IS EMPTY";
        compare(jpql, o);
View Full Code Here

Examples of org.apache.openjpa.persistence.query.DomainObject

        compare(jpql, o);
    }

    public void testNonCorrelatedSubQuery() {
        QueryDefinition q1 = qb.createQueryDefinition();
        DomainObject goodCustomer = q1.addRoot(Customer.class);
       
        QueryDefinition q2 = qb.createQueryDefinition();
        DomainObject customer = q2.addRoot(Customer.class);
       
        q1.where(goodCustomer.get("balanceOwned")
                .lessThan(q2.select(customer.get("balanceOwned").avg())));
       
        String jpql = "select c from Customer c "
                    + " where c.balanceOwned < "
                    + "(select AVG(c2.balanceOwned) from Customer c2)";
        compare(jpql, q1);
View Full Code Here

Examples of org.apache.openjpa.persistence.query.DomainObject

        compare(jpql, q1);
    }

    public void testNew() {
        QueryDefinition q = qb.createQueryDefinition();
        DomainObject customer = q.addRoot(Customer.class);
        DomainObject order = customer.join("orders");
        q.where(order.get("count").greaterThan(100))
         .select(q.newInstance(Customer.class, customer.get("id"),
                                               customer.get("status"),
                                               order.get("count")));
       
       
        String jpql =
            "SELECT NEW org.apache.openjpa.persistence.criteria.Customer"
                + "(c.id, c.status, o.count)"
View Full Code Here

Examples of org.apache.openjpa.persistence.query.DomainObject

        compare(jpql, q);
    }
   
    public void testKeyValueOperatorPath() {
        QueryDefinition q = qb.createQueryDefinition();
        DomainObject v = q.addRoot(VideoStore.class);
        DomainObject i = v.join("videoInventory");
        q.where(v.get("location").get("zipCode").equal("94301").and(
            i.value().greaterThan(0)));
        q.select(v.get("location").get("street"), i.key().get("title"), i
            .value());
       
        String jpql = "SELECT v.location.street, KEY(v2).title, VALUE(v2)"
                    + " FROM VideoStore v JOIN v.videoInventory v2"
                    + " WHERE v.location.zipCode = '94301' AND VALUE(v2) > 0";
View Full Code Here

Examples of org.apache.openjpa.persistence.query.DomainObject

        compare(jpql, q);
    }
   
    public void testGroupByHaving() {
        QueryDefinition q = qb.createQueryDefinition();
        DomainObject customer = q.addRoot(Customer.class);
        q.select(customer.get("status"), customer.get("filledOrderCount").avg(),
                 customer.count())
         .groupBy(customer.get("status"))
         .having(customer.get("status").in(1, 2));
       
        String jpql = "SELECT c.status, AVG(c.filledOrderCount), COUNT(c)"
                    + " FROM Customer c"
                    + " GROUP BY c.status"
                    + " HAVING c.status IN (1, 2)";
View Full Code Here

Examples of org.apache.openjpa.persistence.query.DomainObject

        compare(jpql, q);
    }
   
    public void testGroupByHaving2() {
        QueryDefinition q = qb.createQueryDefinition();
        DomainObject customer = q.addRoot(Customer.class);
        q.select(customer.get("country"), customer.count())
         .groupBy(customer.get("country"))
         .having(customer.count().greaterThan(30));
       
        String jpql = "SELECT c.country, COUNT(c)"
                    + " FROM Customer c"
                    + " GROUP BY c.country"
                    + " HAVING COUNT(c) > 30";
View Full Code Here

Examples of org.apache.openjpa.persistence.query.DomainObject

        compare(jpql, q);
    }
   
    public void testOrderBy() {
        QueryDefinition q = qb.createQueryDefinition();
        DomainObject customer = q.addRoot(Customer.class);
        DomainObject order = customer.join("orders");
        DomainObject address = customer.join("address");
        q.where(address.get("state").equal("CA"))
        .select(order)
        .orderBy(order.get("quantity").desc(), order.get("totalcost"));
        String jpql = "SELECT o"
                    + " FROM Customer c JOIN c.orders o JOIN c.address a"
                    + " WHERE a.state = 'CA'"
View Full Code Here

Examples of org.apache.openjpa.persistence.query.DomainObject

        compare(jpql, q);
    }
   
    public void testOrderBy2() {
        QueryDefinition q = qb.createQueryDefinition();
        DomainObject customer = q.addRoot(Customer.class);
        DomainObject order = customer.join("orders");
        DomainObject address = customer.join("address");
        q.where(address.get("state").equal("CA"))
        .select(order.get("quantity"), address.get("zipCode"))
        .orderBy(order.get("quantity").desc(), address.get("zipCode"));
        String jpql = "SELECT o.quantity, a.zipCode"
                    + " FROM Customer c JOIN c.orders o JOIN c.address a"
                    + " WHERE a.state = 'CA'"
                    + " ORDER BY o.quantity DESC, a.zipCode";
        compare(jpql, q);
View Full Code Here

Examples of org.apache.openjpa.persistence.query.DomainObject

                    + " ORDER BY o.quantity DESC, a.zipCode";
        compare(jpql, q);
    }
   
    public void testOrderByExpression() {
        DomainObject o = qb.createQueryDefinition(Order.class);
        DomainObject a = o.join("customer").join("address");
        SelectItem taxedCost = o.get("cost").times(1.08);
        o.select(o.get("quantity"), taxedCost, a.get("zipCode"))
        .where(a.get("state").equal("CA")
        .and(a.get("county").equal("Santa Clara")))
        .orderBy(o.get("quantity"), taxedCost, a.get("zipCode"));
       
        String jpql = "SELECT o.quantity, o.cost*1.08 as o2, a.zipCode"
                    + " FROM Order o JOIN o.customer c JOIN c.address a"
                    + " WHERE a.state = 'CA' AND a.county = 'Santa Clara'"
                    + " ORDER BY o.quantity, o2, a.zipCode";
View Full Code Here

Examples of org.apache.openjpa.persistence.query.DomainObject

        compare(jpql, o);
    }
   
    public void testCorrelatedSubquery() {
        QueryDefinition q1 = qb.createQueryDefinition();
        DomainObject emp = q1.addRoot(Employee.class);
       
        QueryDefinition q2 = qb.createQueryDefinition();
        DomainObject spouseEmp = q2.addRoot(Employee.class);
       
        q2.where(spouseEmp.equal(emp.get("spouse"))).select(spouseEmp);
        q1.selectDistinct(emp).where(q2.exists());
       
        String jpql = "SELECT DISTINCT e "
                    + " FROM Employee e"
                    + " WHERE EXISTS ("
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.