Package org.apache.openjpa.persistence.query

Examples of org.apache.openjpa.persistence.query.DomainObject.where()


    }

    public void testFetchJoin() {
        DomainObject d = qb.createQueryDefinition(Department.class);
        d.leftJoinFetch("employees");
        d.where(d.get("deptNo").equal(1));
       
       
        String jpql = "select d from Department d" +
                      " LEFT JOIN FETCH d.employees" +
                      " where d.deptNo = 1";
View Full Code Here


   
    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

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

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

        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

        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

        compare(jpql, customer);
    }
   
    public void testTypeList() {
        DomainObject q = qb.createQueryDefinition(Employee.class);
        q.where(q.type().in(Exempt.class, Contractor.class));
       
        String jpql = "SELECT e "
            + " FROM Employee e"
            + " WHERE TYPE(e) IN (Exempt, Contractor)";
       
View Full Code Here

        compare(jpql, q);
    }
   
    public void testStringList() {
        DomainObject q = qb.createQueryDefinition(Customer.class);
        q.where(q.get("country").in("USA", "UK", "France"));
       
        String jpql = "SELECT c "
            + " FROM Customer c"
            + " WHERE c.country IN ('USA', 'UK', 'France')";
        compare(jpql, q);
View Full Code Here

        compare(jpql, o);
    }
   
    public void testRecursiveDefinitionIsNotAllowed() {
        DomainObject q = qb.createQueryDefinition(Customer.class);
        q.where(q.exists().and(q.get("name").equal("wrong")));
       
        try {
            qb.toJPQL(q);
            fail();
        } catch (RuntimeException e) {
View Full Code Here

    }

    public void testFetchJoin() {
        DomainObject d = qb.createQueryDefinition(Department.class);
        d.leftJoinFetch("employees");
        d.where(d.get("deptNo").equal(1));
       
       
        String jpql = "select d from Department d" +
                      " LEFT JOIN FETCH d.employees" +
                      " where d.deptNo = 1";
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.