Examples of DomainObject


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

        compare(jpql, e);
    }
   
    public void testOperatorPath() {
        QueryDefinition qdef = qb.createQueryDefinition();
        DomainObject item = qdef.addRoot(Item.class);
        DomainObject photo = item.join("photos");
        qdef.select(item.get("name"), photo.value())
            .where(photo.key().like("egret"));
       
       
        String jpql = "select i.name, VALUE(p)"
                    + " from Item i join i.photos p"
                    + " where KEY(p) like 'egret'";
View Full Code Here

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

                    + " where KEY(p) like 'egret'";
        compare(jpql, qdef);
    }
   
    public void testLiteral() {
        DomainObject c = qb.createQueryDefinition(Customer.class);
        DomainObject o = c.join("orders");
        DomainObject a = c.join("address");
        o.where(a.get("state").equal("CA").and(
            a.get("county").equal("Santa Clara")));
        o
            .select(o.get("quantity"), o.get("cost").times(1.08), a
                .get("zipCode"));
       
        String jpql = "select o.quantity, o.cost*1.08, a.zipCode" +
                      " from Customer c join c.orders o join c.address a" +
                      " where a.state = 'CA' and a.county = 'Santa Clara'";
View Full Code Here

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

                      " where a.state = 'CA' and a.county = 'Santa Clara'";
        compare(jpql, c);
    }
   
    public void testTypeExpression() {
        DomainObject e = qb.createQueryDefinition(Employee.class);
        e.select(e.type())
         .where(e.type().equal(Exempt.class).not());
       
        String jpql = "select TYPE(e)" +
                      " from Employee e" +
                      " where TYPE(e) <> Exempt";
        compare(jpql, e);
View Full Code Here

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

                      " where TYPE(e) <> Exempt";
        compare(jpql, e);
    }

    public void testIndex() {
        DomainObject c = qb.createQueryDefinition(Course.class);
        DomainObject w = c.join("studentWaitList");
        c.where(c.get("name").equal("Calculus").and(w.index().equal(0)))
         .select(w.get("name"));
       
        String jpql = "select s.name" +
                      " from Course c join c.studentWaitList s" +
                      " where c.name = 'Calculus' and INDEX(s) = 0";
        compare(jpql, c);
View Full Code Here

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

                      " where c.name = 'Calculus' and INDEX(s) = 0";
        compare(jpql, c);
    }
   
    public void testSum() {
        DomainObject o = qb.createQueryDefinition(Order.class);
        DomainObject l = o.join("lineItems");
        DomainObject c = o.join("customer");
        c.where(c.get("lastName").equal("Smith").and(c.get("firstName").
            equal("John"))).select(l.get("price").sum());
       
        String jpql = "select SUM(l.price)" +
                      " from Order o join o.lineItems l JOIN o.customer c" +
                      " where c.lastName = 'Smith' and c.firstName = 'John'";
View Full Code Here

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

                      " where c.lastName = 'Smith' and c.firstName = 'John'";
        compare(jpql, c);
    }
   
    public void testSize() {
        DomainObject d = qb.createQueryDefinition(Department.class);
        d.where(d.get("name").equal("Sales"))
         .select(d.get("employees").size());
       
        String jpql = "select SIZE(d.employees)" +
                      " from Department d " +
                      " where d.name = 'Sales'";
        compare(jpql, d);
View Full Code Here

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

        long count = query.getSingleResult();
        assertEquals(size, count);
    }
   
    public void testGeneralCase() {
        DomainObject e = qb.createQueryDefinition(Employee.class);
        e.where(e.get("department").get("name").equal("Engineering"));
        e.select(e.get("name"),
        e.generalCase()
        .when(e.get("rating").equal(1))
        .then(e.get("salary").times(1.1))
        .when(e.get("rating").equal(2))
        .then(e.get("salary").times(1.2))
        .elseCase(e.get("salary").times(1.01)));
       
        String jpql = "SELECT e.name,"
                    + " CASE WHEN e.rating = 1 THEN e.salary * 1.1"
                    + " WHEN e.rating = 2 THEN e.salary * 1.2"
                    + " ELSE e.salary * 1.01"
 
View Full Code Here

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

       
        compare(jpql, e);
    }
   
    public void testMemberOf() {
        DomainObject p = qb.createQueryDefinition(Person.class);
        p.where(p.literal("Joe").member(p.get("nicknames")));
       
        String jpql = "select p from Person p " +
                      " where 'Joe' MEMBER OF p.nicknames";
        compare(jpql, p);
    }
View Full Code Here

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

        compare(jpql, p);
    }
   
    public void testParamater() {
        QueryDefinition qdef = qb.createQueryDefinition();
        DomainObject customer = qdef.addRoot(Customer.class);
        qdef.where(customer.get("status").equal(qdef.param("status")));
       
        String jpql = "select c from Customer c " +
                      " where c.status = :status";
        compare(jpql, qdef, "status", 1);
    }
View Full Code Here

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

                      " where c.status = :status";
        compare(jpql, qdef, "status", 1);
    }
   
    public void testBetween() {
        DomainObject c = qb.createQueryDefinition(CreditCard.class);
        DomainObject t = c.join("transactionHistory");
        c.select(t).where(c.get("holder").get("name").equal("John Doe")
                .and(t.index().between(0, 9)));
       
       
        String jpql = "select t from CreditCard c JOIN c.transactionHistory t" +
                      " where c.holder.name = 'John Doe' AND INDEX(t) " +
                      " BETWEEN 0 AND 9";
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.