openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r776951 [2/3] - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-kernel/src/main/resources/org/apache/openjpa/meta/ openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ openjpa-persistence-jdbc/src/test/j...
Date Thu, 21 May 2009 05:05:41 GMT
Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypesafeCriteria.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypesafeCriteria.java?rev=776951&r1=776950&r2=776951&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypesafeCriteria.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypesafeCriteria.java Thu May 21 05:05:39 2009
@@ -24,6 +24,7 @@
 
 import javax.persistence.EntityManager;
 import javax.persistence.Parameter;
+import javax.persistence.PersistenceException;
 import javax.persistence.Query;
 import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Join;
@@ -35,421 +36,489 @@
 
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.lib.jdbc.AbstractJDBCListener;
+import org.apache.openjpa.lib.jdbc.JDBCEvent;
+import org.apache.openjpa.lib.jdbc.JDBCListener;
+import org.apache.openjpa.lib.jdbc.ReportingSQLException;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
 import org.apache.openjpa.persistence.test.AllowFailure;
-import org.apache.openjpa.persistence.test.SQLListenerTestCase;
+import org.apache.openjpa.persistence.test.SingleEMFTestCase;
 
 /**
  * Tests type-strict version of Criteria API.
  * 
- * Most of the tests build Criteria Query and then execute the query as well
- * as a reference JPQL query supplied as a string. The test is validated by
- * asserting that the resultant SQL queries for these two alternative form
- * of executing a query are the same.
+ * Most of the tests build Criteria Query and then execute the query as well as
+ * a reference JPQL query supplied as a string. The test is validated by
+ * asserting that the resultant SQL queries for these two alternative form of
+ * executing a query are the same.
+ * 
+ * 
+ * 
+ * @author Pinaki Poddar
  * 
- *
  */
-public class TestTypesafeCriteria extends SQLListenerTestCase {
-    CriteriaBuilder cb;
-    CriteriaQuery c;
-    EntityManager em;
-    
-    public void setUp() {
-         super.setUp(DROP_TABLES,
-                Account.class,
-                Address.class, 
-                Contact.class,
-                Contractor.class, 
-                Course.class, 
-                CreditCard.class, 
-                Customer.class, 
-                Department.class, 
-                Employee.class, 
-                Exempt.class,
-                FrequentFlierPlan.class,
-                Item.class,
-                LineItem.class,
-                Manager.class, 
-                Movie.class,
-                Person.class, 
-                Order.class, 
-                Phone.class,
-                Photo.class,
-                Product.class,
-                Semester.class,
-                Student.class, 
-                TransactionHistory.class,
-                VideoStore.class);
-        
-        setDictionary();
-        cb = (CriteriaBuilder)emf.getQueryBuilder();
-        em = emf.createEntityManager();
-        
-        c = cb.create();
-    }
-    
-    void setDictionary() {
-    	JDBCConfiguration conf = (JDBCConfiguration)emf.getConfiguration();
-    	DBDictionary dict = conf.getDBDictionaryInstance();
-    	dict.requiresCastForComparisons = false;
-    	dict.requiresCastForMathFunctions = false;
-    }
-    
-    public void testRoot() {
-    	String jpql = "select a from Account a";
+public class TestTypesafeCriteria extends CriteriaTest {
+
+    public void testExplictRoot() {
+        String jpql = "select a from Account a";
         CriteriaQuery c = cb.create();
         Root<Account> account = c.from(Account.class);
         c.select(account);
-        
+
         assertEquivalence(c, jpql);
     }
-    
+
     public void testImplicitRoot() {
-    	String jpql = "select a from Account a";
+        String jpql = "select a from Account a";
         CriteriaQuery c = cb.create();
         c.from(Account.class);
-        
+
         assertEquivalence(c, jpql);
     }
-    
-    public void testEqual() {
-    	String jpql = "select a from Account a where a.balance=100";
-    	
+
+    public void testEqualWithAttributeAndLiteral() {
+        String jpql = "select a from Account a where a.balance=100";
+
         CriteriaQuery c = cb.create();
         Root<Account> account = c.from(Account.class);
         c.select(account).where(cb.equal(account.get(Account_.balance), 100));
-        
+
         assertEquivalence(c, jpql);
     }
-    
-    public void testEqual2() {
-    	String jpql = "select a from Account a where a.balance=a.loan";
-    	
+
+    public void testEqualWithAttributeAndAttribute() {
+        String jpql = "select a from Account a where a.balance=a.loan";
+
         CriteriaQuery c = cb.create();
         Root<Account> account = c.from(Account.class);
-        c.select(account).where(cb.equal(account.get(Account_.balance), account.get(Account_.loan)));
-        
+        c.select(account).where(
+                cb.equal(account.get(Account_.balance), account
+                        .get(Account_.loan)));
+
         assertEquivalence(c, jpql);
     }
-    
-    public void testProj() {
-    	String jpql = "select a.balance,a.loan from Account a";
+
+    public void testProjection() {
+        String jpql = "select a.balance,a.loan from Account a";
         CriteriaQuery c = cb.create();
         Root<Account> account = c.from(Account.class);
         c.select(account.get(Account_.balance), account.get(Account_.loan));
         assertEquivalence(c, jpql);
-        
     }
 
-    
-    public void testAbs() {
+    public void testAbsExpression() {
         CriteriaQuery c = cb.create();
         Root<Account> account = c.from(Account.class);
-        
-    	String jpql = "select a from Account a where abs(a.balance)=100";
-        c.select(account).where(cb.equal(cb.abs(account.get(Account_.balance)), 100));
+
+        String jpql = "select a from Account a where abs(a.balance)=100";
+        c.select(account).where(
+                cb.equal(cb.abs(account.get(Account_.balance)), 100));
         assertEquivalence(c, jpql);
     }
-    
-    public void testAvg() {
+
+    public void testAvgExpression() {
         CriteriaQuery c = cb.create();
         Root<Account> account = c.from(Account.class);
-        
-    	String jpql = "select avg(a.balance) from Account a";
+
+        String jpql = "select avg(a.balance) from Account a";
         c.select(cb.avg(account.get(Account_.balance)));
         assertEquivalence(c, jpql);
     }
 
     public void testInPredicate() {
-    	String jpql = "select a from Account a where a.owner in ('X','Y','Z')";
+        String jpql = "select a from Account a where a.name in ('X','Y','Z')";
+        CriteriaQuery c = cb.create();
+        Root<Account> account = c.from(Account.class);
+        c.where(cb.in(account.get(Account_.name)).value("X").value("Y").value(
+                "Z"));
+        assertEquivalence(c, jpql);
+    }
+
+    public void testInPredicateWithPath() {
+        String jpql = "select a from Account a where a.owner.name in ('X','Y','Z')";
         CriteriaQuery c = cb.create();
         Root<Account> account = c.from(Account.class);
-        c.where(cb.in(account.get(Account_.owner)).value("X").value("Y").value("Z"));
+        c.where(cb.in(account.get(Account_.owner).get(Person_.name)).value("X")
+                .value("Y").value("Z"));
         assertEquivalence(c, jpql);
     }
-    
+
     public void testBinaryPredicate() {
-    	String jpql = "select a from Account a where a.balance>100 and a.balance<200";
-    	
+        String jpql = "select a from Account a where a.balance>100 and a.balance<200";
+
         CriteriaQuery c = cb.create();
         Root<Account> account = c.from(Account.class);
-        c.select(account).where(cb.and(
-          cb.greaterThan(account.get(Account_.balance), 100),
-          cb.lessThan(account.get(Account_.balance), 200)));
-        
+        c.select(account).where(
+                cb.and(cb.greaterThan(account.get(Account_.balance), 100), cb
+                        .lessThan(account.get(Account_.balance), 200)));
+
         assertEquivalence(c, jpql);
     }
-    
-    public void testUnaryExpression() {
-    	String jpql = "select a from Account a where a.balance=abs(a.balance)";
-    	
+
+    public void testEqualWithAttributeAndUnaryExpression() {
+        String jpql = "select a from Account a where a.balance=abs(a.balance)";
+
         CriteriaQuery c = cb.create();
         Root<Account> account = c.from(Account.class);
-        c.select(account).where(cb.equal(account.get(Account_.balance), cb.abs(account.get(Account_.balance))));
-        
+        c.select(account).where(
+                cb.equal(account.get(Account_.balance), cb.abs(account
+                        .get(Account_.balance))));
+
         assertEquivalence(c, jpql);
     }
-    
+
     public void testBetweenExpression() {
-    	String jpql = "select a from Account a where a.balance between 100 and 200";
-    	
+        String jpql = "select a from Account a where a.balance between 100 and 200";
+
         CriteriaQuery c = cb.create();
         Root<Account> account = c.from(Account.class);
-        c.select(account).where(cb.between(account.get(Account_.balance), 100, 200));
-        
+        c.select(account).where(
+                cb.between(account.get(Account_.balance), 100, 200));
+
         assertEquivalence(c, jpql);
     }
 
-    public void testSimpleJoin() {
+    public void testSimplePath() {
+        String jpql = "select a from Account a where a.owner.name='Pinaki'";
         CriteriaQuery c = cb.create();
-//        c.from(Account.class).join(Account_.history)
+        Root<Account> a = c.from(Account.class);
+        c.where(cb.equal(a.get(Account_.owner).get(Person_.name), "Pinaki"));
+
+        assertEquivalence(c, jpql);
     }
-    
-    @AllowFailure
-    public void testJoins1() {
-        String jpql = "SELECT c.name FROM Customer c JOIN c.orders o " + 
-            "JOIN o.lineItems i WHERE i.product.productType = 'printer'";
+
+    public void testSimpleLeftJoin() {
+        String jpql = "SELECT c FROM Customer c LEFT JOIN c.orders o ";
+        CriteriaQuery c = cb.create();
+        c.from(Customer.class).join(Customer_.orders, JoinType.LEFT);
+        assertEquivalence(c, jpql);
+    }
+
+    @AllowFailure(message = "Extra joins created in Criteria")
+    public void testMultiLevelJoins() {
+        String jpql = "SELECT c FROM Customer c JOIN c.orders o "
+                + "JOIN o.lineItems i WHERE i.product.productType = 'printer'";
+
         CriteriaQuery c = cb.create();
         Root<Customer> cust = c.from(Customer.class);
         Join<Customer, Order> order = cust.join(Customer_.orders);
         Join<Order, LineItem> item = order.join(Order_.lineItems);
-        c.select(cust.get(Customer_.name))
-            .where(cb.equal(item.get(LineItem_.product).
-            get(Product_.productType), "printer"));
-        
+        c.where(cb.equal(item.get(LineItem_.product).get(Product_.productType),
+                "printer"));
         assertEquivalence(c, jpql);
     }
-    
-    @AllowFailure
-    public void testJoins2() {
-        String jpql = "SELECT c FROM Customer c LEFT JOIN c.orders o " + 
-            "WHERE c.status = 1";
-        c = cb.create();
+
+    public void testJoinsNotPresentInWhereClause() {
+        String jpql = "SELECT c FROM Customer c LEFT JOIN c.orders o "
+                + "WHERE c.status = 1";
+        CriteriaQuery c = cb.create();
         Root<Customer> cust = c.from(Customer.class);
-        Join<Customer, Order> order = cust.join(Customer_.orders, 
-            JoinType.LEFT);
+        Join<Customer, Order> order = cust
+                .join(Customer_.orders, JoinType.LEFT);
         c.where(cb.equal(cust.get(Customer_.status), 1)).select(cust);
-        
+
         assertEquivalence(c, jpql);
     }
-    
-    @AllowFailure
+
+    @AllowFailure(message = "Fetch joins not implemented")
     public void testFetchJoins() {
-        String jpql = "SELECT d FROM Department LEFT JOIN FETCH d.employees " + 
-            "WHERE d.deptNo = 1";
+        String jpql = "SELECT d FROM Department LEFT JOIN FETCH d.employees "
+                + "WHERE d.deptNo = 1";
         CriteriaQuery q = cb.create();
         Root<Department> d = q.from(Department.class);
         d.fetch(Department_.employees, JoinType.LEFT);
         q.where(cb.equal(d.get(Department_.deptNo), 1)).select(d);
-        
+
         assertEquivalence(q, jpql);
     }
-    
-    @AllowFailure
-    public void testPathNavigation1() {
-        String jpql = "SELECT p.vendor FROM Employee e JOIN " + 
-            "e.contactInfo.phones p " + 
-            "WHERE e.contactInfo.address.zipCode = '95054'";
+
+    @AllowFailure(message = "Invalid SQL is generated")
+    public void testJoinedPathInProjection() {
+        String jpql = "SELECT p.vendor FROM Employee e JOIN "
+                + "e.contactInfo.phones p "
+                + "WHERE e.contactInfo.address.zipCode = '95054'";
         CriteriaQuery q = cb.create();
         Root<Employee> emp = q.from(Employee.class);
-        Join<Contact, Phone> phone = emp.join(Employee_.contactInfo).
-            join(Contact_.phones);
-        q.where(cb.equal(emp.get(Employee_.contactInfo).get(Contact_.address).
-            get(Address_.zipCode), "95054"));    
-        q.select(phone.get(Phone_.vendor));        
-        
+        Join<Contact, Phone> phone = emp.join(Employee_.contactInfo).join(
+                Contact_.phones);
+        q.where(cb.equal(emp.get(Employee_.contactInfo).get(Contact_.address)
+                .get(Address_.zipCode), "95054"));
+        q.select(phone.get(Phone_.vendor));
+
         assertEquivalence(q, jpql);
     }
-    
-    @AllowFailure
-    public void testPathNavigation2() {
-        String jpql = "SELECT i.name, p FROM Item i JOIN i.photos p WHERE KEY(p) " + 
-            "LIKE '%egret%'";
+
+    @AllowFailure(message = "Key expression not implemented")
+    public void testKeyExpression() {
+        String jpql = "SELECT i.name, p FROM Item i JOIN i.photos p WHERE KEY(p) "
+                + "LIKE '%egret%'";
         CriteriaQuery q = cb.create();
         Root<Item> item = q.from(Item.class);
         MapJoin<Item, String, Photo> photo = item.join(Item_.photos);
-        q.select(item.get(Item_.name), photo).
-            where(cb.like(photo.key(), "%egret%"));
-        
+        q.select(item.get(Item_.name), photo).where(
+                cb.like(photo.key(), "%egret%"));
+
         assertEquivalence(q, jpql);
     }
-    
-    @AllowFailure
-    public void testRestrictQueryResult1() {
-        String jpql = "SELECT t FROM CreditCard c JOIN c.transactionHistory t " 
-            + "WHERE c.customer.accountNum = 321987 AND INDEX(t) BETWEEN 0 " 
-            + "AND 9";
+
+    @AllowFailure(message = "Index expression not implemented")
+    public void testIndexExpression() {
+        String jpql = "SELECT t FROM CreditCard c JOIN c.transactionHistory t "
+                + "WHERE c.customer.accountNum = 321987 AND INDEX(t) BETWEEN 0 "
+                + "AND 9";
         CriteriaQuery q = cb.create();
         Root<CreditCard> c = q.from(CreditCard.class);
-        ListJoin<CreditCard, TransactionHistory> t = 
-            c.join(CreditCard_.transactionHistory);
-        q.select(t).where(cb.equal(
-            c.get(CreditCard_.customer).get(Customer_.accountNum), 321987),
-            cb.between(t.index(), 0, 9));
-        
+        ListJoin<CreditCard, TransactionHistory> t = c
+                .join(CreditCard_.transactionHistory);
+        q.select(t).where(
+                cb.equal(c.get(CreditCard_.customer).get(Customer_.accountNum),
+                        321987), cb.between(t.index(), 0, 9));
+
         assertEquivalence(q, jpql);
     }
-    
-    public void testRestrictQueryResult2() {
+
+    public void testIsEmptyExpression() {
         String jpql = "SELECT o FROM Order o WHERE o.lineItems IS EMPTY";
         CriteriaQuery q = cb.create();
         Root<Order> order = q.from(Order.class);
         q.where(cb.isEmpty(order.get(Order_.lineItems))).select(order);
-        
+
+        assertEquivalence(q, jpql);
+    }
+
+    @AllowFailure(message = "broken")
+    public void testExpressionInProjection() {
+        String jpql = "SELECT o.quantity, o.totalCost*1.08 AS taxedCost, "
+                + "a.zipCode FROM Customer c JOIN c.orders o JOIN c.address a "
+                + "WHERE a.state = 'CA' AND a.county = 'Santa Clara'";
+        CriteriaQuery q = cb.create();
+        Root<Customer> cust = q.from(Customer.class);
+        Join<Customer, Order> order = cust.join(Customer_.orders);
+        Join<Customer, Address> address = cust.join(Customer_.address);
+        q.where(cb.equal(address.get(Address_.state), "CA"), cb.equal(address
+                .get(Address_.county), "Santa Clara"));
+        q.select(order.get(Order_.quantity), cb.prod(order
+                .get(Order_.totalCost), 1.08), address.get(Address_.zipCode));
+
+        assertEquivalence(q, jpql);
+    }
+
+    @AllowFailure(message = "Type expression was working with Fay. Now refactored and broken")
+    public void testTypeExpression() {
+        String jpql = "SELECT TYPE(e) FROM Employee e WHERE TYPE(e) <> Exempt";
+        CriteriaQuery q = cb.create();
+        Root<Employee> emp = q.from(Employee.class);
+        q.select(emp.type()).where(cb.notEqual(emp.type(), Exempt.class));
+
+        assertEquivalence(q, jpql);
+    }
+
+    @AllowFailure(message = "Index expression not implemented")
+    public void testIndexExpressionAndLietral() {
+        String jpql = "SELECT w.name FROM Course c JOIN c.studentWaitList w "
+                + "WHERE c.name = 'Calculus' AND INDEX(w) = 0";
+        CriteriaQuery q = cb.create();
+        Root<Course> course = q.from(Course.class);
+        ListJoin<Course, Student> w = course.join(Course_.studentWaitList);
+        q.where(cb.equal(course.get(Course_.name), "Calculus"),
+                cb.equal(w.index(), 0)).select(w.get(Student_.name));
+
+        assertEquivalence(q, jpql);
+    }
+
+    @AllowFailure(message = "SQL for Criteria has extra join")
+    public void testAggregateInProjection() {
+        String jpql = "SELECT SUM(i.price) FROM Order o JOIN o.lineItems i JOIN "
+                + "o.customer c WHERE c.lastName = 'Smith' AND c.firstName = 'John'";
+        CriteriaQuery q = cb.create();
+        Root<Order> o = q.from(Order.class);
+        Join<Order, LineItem> i = o.join(Order_.lineItems);
+        Join<Order, Customer> c = o.join(Order_.customer);
+        q.where(cb.equal(c.get(Customer_.lastName), "Smith"), cb.equal(c
+                .get(Customer_.firstName), "John"));
+        q.select(cb.sum(i.get(LineItem_.price)));
+
+        assertEquivalence(q, jpql);
+    }
+
+    public void testSizeExpression() {
+        String jpql = "SELECT SIZE(d.employees) FROM Department d "
+                + "WHERE d.name = 'Sales'";
+        CriteriaQuery q = cb.create();
+        Root<Department> d = q.from(Department.class);
+        q.where(cb.equal(d.get(Department_.name), "Sales"));
+        q.select(cb.size(d.get(Department_.employees)));
+
+        assertEquivalence(q, jpql);
+    }
+
+    public void testCaseExpression() {
+        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 END "
+                + "FROM Employee e WHERE e.department.name = 'Engineering'";
+        CriteriaQuery q = cb.create();
+        Root<Employee> e = q.from(Employee.class);
+        q.where(cb.equal(e.get(Employee_.department).get(Department_.name),
+                "Engineering"));
+        q.select(e.get(Employee_.name), cb.selectCase().when(
+                cb.equal(e.get(Employee_.rating), 1),
+                cb.prod(e.get(Employee_.salary), 1.1)).when(
+                cb.equal(e.get(Employee_.rating), 2),
+                cb.prod(e.get(Employee_.salary), 1.2)).otherwise(
+                cb.prod(e.get(Employee_.salary), 1.01)));
+
         assertEquivalence(q, jpql);
     }
 
-    @AllowFailure
+    @AllowFailure(message = "Extra Joins created")
     public void testExpression1() {
-        String jpql = "SELECT o.quantity, o.totalCost*1.08 AS taxedCost, "  
-            + "a.zipCode FROM Customer c JOIN c.orders o JOIN c.address a " 
-            + "WHERE a.state = 'CA' AND a.county = 'Santa Clara";
+        String jpql = "SELECT o.quantity, o.totalCost*1.08 AS taxedCost, "
+                + "a.zipCode FROM Customer c JOIN c.orders o JOIN c.address a "
+                + "WHERE a.state = 'CA' AND a.county = 'Santa Clara'";
         CriteriaQuery q = cb.create();
         Root<Customer> cust = q.from(Customer.class);
         Join<Customer, Order> order = cust.join(Customer_.orders);
         Join<Customer, Address> address = cust.join(Customer_.address);
-        q.where(cb.equal(address.get(Address_.state), "CA"),
-            cb.equal(address.get(Address_.county), "Santa Clara"));
-        q.select(order.get(Order_.quantity), 
-            cb.prod(order.get(Order_.totalCost), 1.08),
-            address.get(Address_.zipCode));
-        
+        q.where(cb.equal(address.get(Address_.state), "CA"), cb.equal(address
+                .get(Address_.county), "Santa Clara"));
+        q.select(order.get(Order_.quantity), cb.prod(order
+                .get(Order_.totalCost), 1.08), address.get(Address_.zipCode));
+
         assertEquivalence(q, jpql);
     }
-    
+
+    @AllowFailure(message = "Type expression in projection not implemented")
     public void testExpression2() {
         String jpql = "SELECT TYPE(e) FROM Employee e WHERE TYPE(e) <> Exempt";
         CriteriaQuery q = cb.create();
         Root<Employee> emp = q.from(Employee.class);
         q.select(emp.type()).where(cb.notEqual(emp.type(), Exempt.class));
-        
+
         assertEquivalence(q, jpql);
     }
-    
-    @AllowFailure
+
+    @AllowFailure(message = "Index expression not implemented")
     public void testExpression3() {
-        String jpql = "SELECT w.name FROM Course c JOIN c.studentWaitList w " + 
-            "WHERE c.name = 'Calculus' AND INDEX(w) = 0";
+        String jpql = "SELECT w.name FROM Course c JOIN c.studentWaitList w "
+                + "WHERE c.name = 'Calculus' AND INDEX(w) = 0";
         CriteriaQuery q = cb.create();
         Root<Course> course = q.from(Course.class);
         ListJoin<Course, Student> w = course.join(Course_.studentWaitList);
-        q.where(cb.equal(course.get(Course_.name), "Calculus"), 
+        q.where(cb.equal(course.get(Course_.name), "Calculus"),
                 cb.equal(w.index(), 0)).select(w.get(Student_.name));
-        
+
         assertEquivalence(q, jpql);
     }
-    
-    @AllowFailure
+
+    @AllowFailure(message = "Generates extra Join")
     public void testExpression4() {
-        String jpql = "SELECT SUM(i.price) FROM Order o JOIN o.lineItems i JOIN " +
-            "o.customer c WHERE c.lastName = 'Smith' AND c.firstName = 'John'";
+        String jpql = "SELECT SUM(i.price) FROM Order o JOIN o.lineItems i JOIN "
+                + "o.customer c WHERE c.lastName = 'Smith' AND c.firstName = 'John'";
         CriteriaQuery q = cb.create();
         Root<Order> o = q.from(Order.class);
         Join<Order, LineItem> i = o.join(Order_.lineItems);
         Join<Order, Customer> c = o.join(Order_.customer);
-        q.where(cb.equal(c.get(Customer_.lastName), "Smith"),
-                cb.equal(c.get(Customer_.firstName),"John"));
+        q.where(cb.equal(c.get(Customer_.lastName), "Smith"), cb.equal(c
+                .get(Customer_.firstName), "John"));
         q.select(cb.sum(i.get(LineItem_.price)));
-        
+
         assertEquivalence(q, jpql);
     }
-    
+
     public void testExpression5() {
-        String jpql = "SELECT SIZE(d.employees) FROM Department d " + 
-            "WHERE d.name = 'Sales'";
+        String jpql = "SELECT SIZE(d.employees) FROM Department d "
+                + "WHERE d.name = 'Sales'";
         CriteriaQuery q = cb.create();
         Root<Department> d = q.from(Department.class);
         q.where(cb.equal(d.get(Department_.name), "Sales"));
         q.select(cb.size(d.get(Department_.employees)));
-        
+
         assertEquivalence(q, jpql);
-    } 
-    
+    }
+
     public void testGeneralCaseExpression() {
-        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 END " +
-            "FROM Employee e WHERE e.department.name = 'Engineering'";
+        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 END "
+                + "FROM Employee e WHERE e.department.name = 'Engineering'";
         CriteriaQuery q = cb.create();
         Root<Employee> e = q.from(Employee.class);
-        q.where(cb.equal(e.get(Employee_.department).get(Department_.name), 
-            "Engineering"));
-        q.select(e.get(Employee_.name), 
-            cb.selectCase()
-                .when(cb.equal(e.get(Employee_.rating), 1),
-                    cb.prod(e.get(Employee_.salary), 1.1))
-                .when(cb.equal(e.get(Employee_.rating), 2), 
-                    cb.prod(e.get(Employee_.salary), 1.2))
-                .otherwise(cb.prod(e.get(Employee_.salary), 1.01)));    
+        q.where(cb.equal(e.get(Employee_.department).get(Department_.name),
+                "Engineering"));
+        q.select(e.get(Employee_.name), cb.selectCase().when(
+                cb.equal(e.get(Employee_.rating), 1),
+                cb.prod(e.get(Employee_.salary), 1.1)).when(
+                cb.equal(e.get(Employee_.rating), 2),
+                cb.prod(e.get(Employee_.salary), 1.2)).otherwise(
+                cb.prod(e.get(Employee_.salary), 1.01)));
 
         assertEquivalence(q, jpql);
-    }    
-    
+    }
+
     public void testSimpleCaseExpression1() {
-        String jpql = "SELECT e.name, CASE e.rating " + 
-            "WHEN 1 THEN e.salary * 1.1 " +
-            "WHEN 2 THEN e.salary * 1.2 ELSE e.salary * 1.01 END " +
-            "FROM Employee e WHERE e.department.name = 'Engineering'";
+        String jpql = "SELECT e.name, CASE e.rating "
+                + "WHEN 1 THEN e.salary * 1.1 "
+                + "WHEN 2 THEN e.salary * 1.2 ELSE e.salary * 1.01 END "
+                + "FROM Employee e WHERE e.department.name = 'Engineering'";
         CriteriaQuery q = cb.create();
         Root<Employee> e = q.from(Employee.class);
-        q.where(cb.equal(e.get(Employee_.department).get(Department_.name), 
-            "Engineering"));
-        q.select(e.get(Employee_.name), 
-            cb.selectCase(e.get(Employee_.rating))
-                .when(1, cb.prod(e.get(Employee_.salary), 1.1))
-                .when(2, cb.prod(e.get(Employee_.salary), 1.2))
-                .otherwise(cb.prod(e.get(Employee_.salary), 1.01)));    
+        q.where(cb.equal(e.get(Employee_.department).get(Department_.name),
+                "Engineering"));
+        q.select(e.get(Employee_.name), cb.selectCase(e.get(Employee_.rating))
+                .when(1, cb.prod(e.get(Employee_.salary), 1.1)).when(2,
+                        cb.prod(e.get(Employee_.salary), 1.2)).otherwise(
+                        cb.prod(e.get(Employee_.salary), 1.01)));
 
         assertEquivalence(q, jpql);
     }
-    
+
     public void testSimpleCaseExpression2() {
-        String jpql = "SELECT e.name, CASE e.rating WHEN 1 THEN 10 " +
-            "WHEN 2 THEN 20 ELSE 30 END " +
-            "FROM Employee e WHERE e.department.name = 'Engineering'";
+        String jpql = "SELECT e.name, CASE e.rating WHEN 1 THEN 10 "
+                + "WHEN 2 THEN 20 ELSE 30 END "
+                + "FROM Employee e WHERE e.department.name = 'Engineering'";
         CriteriaQuery q = cb.create();
         Root<Employee> e = q.from(Employee.class);
-        q.where(cb.equal(e.get(Employee_.department).get(Department_.name), 
-            "Engineering"));
-        q.select(e.get(Employee_.name), 
-            cb.selectCase(e.get(Employee_.rating))
-                .when(1, 10)
-                .when(2, 20)
-                .otherwise(30));    
+        q.where(cb.equal(e.get(Employee_.department).get(Department_.name),
+                "Engineering"));
+        q.select(e.get(Employee_.name), cb.selectCase(e.get(Employee_.rating))
+                .when(1, 10).when(2, 20).otherwise(30));
         assertEquivalence(q, jpql);
-    }    
-    
+    }
+
     public void testLiterals() {
         String jpql = "SELECT p FROM Person p where 'Joe' MEMBER OF p.nickNames";
         CriteriaQuery q = cb.create();
         Root<Person> p = q.from(Person.class);
-        q.select(p).where(cb.isMember(cb.literal("Joe"), p.get(
-            Person_.nickNames)));
-        
+        q.select(p).where(
+                cb.isMember(cb.literal("Joe"), p.get(Person_.nickNames)));
+
         assertEquivalence(q, jpql);
     }
-    
+
+    // @AllowFailure(message = "Parameters not implemented")
     public void testParameters1() {
         String jpql = "SELECT c FROM Customer c Where c.status = :stat";
         CriteriaQuery q = cb.create();
         Root<Customer> c = q.from(Customer.class);
         Parameter<Integer> param = cb.parameter(Integer.class, "stat");
         q.select(c).where(cb.equal(c.get(Customer_.status), param));
-        
-        assertEquivalence(q, jpql, new String[]{"stat"}, new Object[] {1});
+
+        assertEquivalence(q, jpql, new String[] { "stat" }, new Object[] { 1 });
     }
 
     public void testParameters2() {
-        String jpql = "SELECT c FROM Customer c Where c.status = :stat AND " + 
-            "c.name = :name";
+        String jpql = "SELECT c FROM Customer c Where c.status = :stat AND "
+                + "c.name = :name";
         CriteriaQuery q = cb.create();
         Root<Customer> c = q.from(Customer.class);
         Parameter<Integer> param1 = cb.parameter(Integer.class, "stat");
         Parameter<String> param2 = cb.parameter(String.class, "name");
-        q.select(c).where(cb.and(cb.equal(c.get(Customer_.status), param1),
-            cb.equal(c.get(Customer_.name), param2)));
+        q.select(c).where(
+                cb.and(cb.equal(c.get(Customer_.status), param1), cb.equal(c
+                        .get(Customer_.name), param2)));
 
-        assertEquivalence(q, jpql, new String[] { "stat", "name" }, 
-            new Object[] { 1, "test" });
+        assertEquivalence(q, jpql, new String[] { "stat", "name" },
+                new Object[] { 1, "test" });
     }
 
     public void testParameters3() {
@@ -461,88 +530,87 @@
         assertEquivalence(q, jpql, new Object[] { 1 });
     }
 
+    @AllowFailure(message="add QuotedNumbersInQueries=true otherwise AbstractExpressionBuilder.convertTypes() compliants")
     public void testParameters4() {
-        String jpql = "SELECT c FROM Customer c Where c.status = ?1 AND " + 
-            "c.name = ?2";
+        String jpql = "SELECT c FROM Customer c Where c.status = ?1 AND "
+                + "c.name = ?2";
         CriteriaQuery q = cb.create();
         Root<Customer> c = q.from(Customer.class);
         Parameter<Integer> param1 = cb.parameter(Integer.class);
         Parameter<Integer> param2 = cb.parameter(Integer.class);
-        q.select(c).where(cb.and(cb.equal(c.get(Customer_.status), param1),
-            cb.equal(c.get(Customer_.name), param2)));    
+        q.select(c).where(
+                cb.and(cb.equal(c.get(Customer_.status), param1), cb.equal(c
+                        .get(Customer_.name), param2)));
         assertEquivalence(q, jpql, new Object[] { 1, "test" });
     }
-    
-    // do not support collection-valued input parameter
-    @AllowFailure
+
+    // @AllowFailure(message = "")
     public void testParameters5() {
         String jpql = "SELECT c FROM Customer c Where c.status IN (:coll)";
         CriteriaQuery q = cb.create();
         Root<Customer> c = q.from(Customer.class);
         Parameter<List> param1 = cb.parameter(List.class);
-        //q.select(c).where(cb.in(c.get(Customer_.status)).value(params1));    
+        // q.select(c).where(cb.in(c.get(Customer_.status)).value(params1));
         List vals = new ArrayList();
         vals.add(1);
         vals.add(2);
-        
-        //assertEquivalence(q, jpql,  new String[] {"coll"}, new Object[] {vals});
+
+        // assertEquivalence(q, jpql, new String[] {"coll"}, new Object[]
+        // {vals});
     }
-    
-    @AllowFailure
+
+    @AllowFailure(message="Value() expression not implemented")
     public void testSelectList1() {
-        String jpql = "SELECT v.location.street, KEY(i).title, VALUE(i) FROM " + 
-            "VideoStore v JOIN v.videoInventory i WHERE v.location.zipCode = " + 
-            "'94301' AND VALUE(i) > 0";
+        String jpql = "SELECT v.location.street, KEY(i).title, VALUE(i) FROM "
+                + "VideoStore v JOIN v.videoInventory i WHERE v.location.zipCode = "
+                + "'94301' AND VALUE(i) > 0";
         CriteriaQuery q = cb.create();
         Root<VideoStore> v = q.from(VideoStore.class);
-        MapJoin<VideoStore, Movie, Integer> inv = v.join(
-            VideoStore_.videoInventory);
-        q.where(cb.equal(v.get(VideoStore_.location).get(Address_.zipCode), 
-            "94301"),
-            cb.gt(inv.value(), 0));
-        q.select(v.get(VideoStore_.location).get(Address_.street), 
-            inv.key().get(Movie_.title), inv.value());
-        
+        MapJoin<VideoStore, Movie, Integer> inv = v
+                .join(VideoStore_.videoInventory);
+        q.where(cb.equal(v.get(VideoStore_.location).get(Address_.zipCode),
+                "94301"), cb.gt(inv.value(), 0));
+        q.select(v.get(VideoStore_.location).get(Address_.street), inv.key()
+                .get(Movie_.title), inv.value());
+
         assertEquivalence(q, jpql);
     }
-    
-    @AllowFailure
+
+    @AllowFailure(message="new() in projection is broken")
     public void testSelectList2() {
-        String jpql = "SELECT NEW CustomerDetails(c.id, c.status, o.quantity) FROM " + 
-        "Customer c JOIN c.orders o WHERE o.quantity > 100";
+        String jpql = "SELECT NEW CustomerDetails(c.id, c.status, o.quantity) FROM "
+                + "Customer c JOIN c.orders o WHERE o.quantity > 100";
         CriteriaQuery q = cb.create();
         Root<Customer> c = q.from(Customer.class);
         Join<Customer, Order> o = c.join(Customer_.orders);
         q.where(cb.gt(o.get(Order_.quantity), 100));
-        q.select(cb.select(CustomerDetails.class, 
-                c.get(Customer_.id),
-                c.get(Customer_.status),
-                o.get(Order_.quantity)));
-        
+        q.select(cb.select(CustomerDetails.class, c.get(Customer_.id), c
+                .get(Customer_.status), o.get(Order_.quantity)));
+
         assertEquivalence(q, jpql);
     }
 
-    @AllowFailure
+    @AllowFailure(message="Subqueries not implemented")
     public void testSubqueries1() {
-        String jpql = "SELECT goodCustomer FROM Customer goodCustomer WHERE " + 
-            "goodCustomer.balanceOwed < (SELECT AVG(c.balanceOwed) FROM " + 
-            "Customer c)";
+        String jpql = "SELECT goodCustomer FROM Customer goodCustomer WHERE "
+                + "goodCustomer.balanceOwed < (SELECT AVG(c.balanceOwed) FROM "
+                + "Customer c)";
         CriteriaQuery q = cb.create();
         Root<Customer> goodCustomer = q.from(Customer.class);
         Subquery<Double> sq = q.subquery(Double.class);
         Root<Customer> c = sq.from(Customer.class);
-        q.where(cb.lt(goodCustomer.get(Customer_.balanceOwed), 
-            sq.select(cb.avg(c.get(Customer_.balanceOwed)))));
+        q.where(cb.lt(goodCustomer.get(Customer_.balanceOwed), sq.select(cb
+                .avg(c.get(Customer_.balanceOwed)))));
         q.select(goodCustomer);
-        
+
         assertEquivalence(q, jpql);
     }
-    
-    @AllowFailure
+
+    @AllowFailure(message="Subqueries not implemented")
     public void testSubqueries2() {
-        String jpql = "SELECT DISTINCT emp FROM Employee emp WHERE EXISTS (" + 
-            "SELECT spouseEmp FROM Employee spouseEmp WHERE spouseEmp = " + 
-            "emp.spouse)";
+        String jpql = "SELECT DISTINCT emp FROM Employee emp WHERE EXISTS ("
+                + "SELECT spouseEmp FROM Employee spouseEmp WHERE spouseEmp = "
+                + "emp.spouse)";
         CriteriaQuery q = cb.create();
         Root<Employee> emp = q.from(Employee.class);
         Subquery<Employee> sq = q.subquery(Employee.class);
@@ -551,147 +619,196 @@
         sq.where(cb.equal(spouseEmp, emp.get(Employee_.spouse)));
         q.where(cb.exists(sq));
         q.select(emp).distinct(true);
-        
+
         assertEquivalence(q, jpql);
     }
-    
-    @AllowFailure
+
+    @AllowFailure(message="Subqueries not implemented")
     public void testSubqueries3() {
-        String jpql = "SELECT emp FROM Employee emp WHERE emp.salary > ALL (" + 
-            "SELECT m.salary FROM Manager m WHERE m.department = " + 
-            "emp.department)";
+        String jpql = "SELECT emp FROM Employee emp WHERE emp.salary > ALL ("
+                + "SELECT m.salary FROM Manager m WHERE m.department = "
+                + "emp.department)";
         CriteriaQuery q = cb.create();
         Root<Employee> emp = q.from(Employee.class);
         q.select(emp);
         Subquery<BigDecimal> sq = q.subquery(BigDecimal.class);
         Root<Manager> m = sq.from(Manager.class);
         sq.select(m.get(Manager_.salary));
-        sq.where(cb.equal(m.get(Manager_.department), emp.get(
-            Employee_.department)));
+        sq.where(cb.equal(m.get(Manager_.department), emp
+                .get(Employee_.department)));
         q.where(cb.gt(emp.get(Employee_.salary), cb.all(sq)));
-    
+
         assertEquivalence(q, jpql);
     }
-    
-    @AllowFailure
+
+    @AllowFailure(message="Subqueries not implemented")
     public void testSubqueries4() {
-        String jpql = "SELECT c FROM Customer c WHERE " + 
-            "(SELECT COUNT(o) FROM c.orders o) > 10";
+        String jpql = "SELECT c FROM Customer c WHERE "
+                + "(SELECT COUNT(o) FROM c.orders o) > 10";
         CriteriaQuery q = cb.create();
         Root<Customer> c1 = q.from(Customer.class);
         q.select(c1);
         Subquery<Long> sq3 = q.subquery(Long.class);
-        Root<Customer> c2 = sq3.correlate(c1); 
-        Join<Customer,Order> o = c2.join(Customer_.orders);
+        Root<Customer> c2 = sq3.correlate(c1);
+        Join<Customer, Order> o = c2.join(Customer_.orders);
         q.where(cb.gt(sq3.select(cb.count(o)), 10));
-        
+
         assertEquivalence(q, jpql);
     }
-    
-    @AllowFailure
+
+    @AllowFailure(message="Subqueries not implemented")
     public void testSubqueries5() {
-        String jpql = "SELECT o FROM Order o WHERE 10000 < ALL (" + 
-            "SELECT a.balance FROM o.customer c JOIN c.accounts a)";
+        String jpql = "SELECT o FROM Order o WHERE 10000 < ALL ("
+                + "SELECT a.balance FROM o.customer c JOIN c.accounts a)";
         CriteriaQuery q = cb.create();
         Root<Order> o = q.from(Order.class);
         q.select(o);
         Subquery<Integer> sq = q.subquery(Integer.class);
         Root<Order> osq = sq.correlate(o);
-        Join<Order,Customer> c = osq.join(Order_.customer);
-        Join<Customer,Account> a = c.join(Customer_.accounts);
+        Join<Order, Customer> c = osq.join(Order_.customer);
+        Join<Customer, Account> a = c.join(Customer_.accounts);
         sq.select(a.get(Account_.balance));
         q.where(cb.lt(cb.literal(10000), cb.all(sq)));
-        
+
         assertEquivalence(q, jpql);
     }
-    
-    @AllowFailure
+
+    @AllowFailure(message="Subqueries not implemented")
     public void testSubqueries6() {
-        String jpql = "SELECT o FROM Order o JOIN o.customer c WHERE 10000 < " +
-            "ALL (SELECT a.balance FROM c.accounts a)";
+        String jpql = "SELECT o FROM Order o JOIN o.customer c WHERE 10000 < "
+                + "ALL (SELECT a.balance FROM c.accounts a)";
         CriteriaQuery q = cb.create();
         Root<Order> o = q.from(Order.class);
         q.select(o);
-        Join<Order,Customer> c = o.join(Order_.customer);
+        Join<Order, Customer> c = o.join(Order_.customer);
         Subquery<Integer> sq = q.subquery(Integer.class);
-        Join<Order,Customer> csq = sq.correlate(c);
-        Join<Customer,Account> a = csq.join(Customer_.accounts);
+        Join<Order, Customer> csq = sq.correlate(c);
+        Join<Customer, Account> a = csq.join(Customer_.accounts);
         sq.select(a.get(Account_.balance));
         q.where(cb.lt(cb.literal(10000), cb.all(sq)));
-        
+
         assertEquivalence(q, jpql);
     }
-    
+
     public void testGroupByAndHaving() {
         String jpql = "SELECT c.status, AVG(c.filledOrderCount), COUNT(c) FROM "
-            + "Customer c GROUP BY c.status HAVING c.status IN (1, 2)";
+                + "Customer c GROUP BY c.status HAVING c.status IN (1, 2)";
         CriteriaQuery q = cb.create();
         Root<Customer> c = q.from(Customer.class);
         q.groupBy(c.get(Customer_.status));
         q.having(cb.in(c.get(Customer_.status)).value(1).value(2));
-        q.select(c.get(Customer_.status), 
-            cb.avg(c.get(Customer_.filledOrderCount)),
-            cb.count(c));
-        
+        q.select(c.get(Customer_.status), cb.avg(c
+                .get(Customer_.filledOrderCount)), cb.count(c));
+
         assertEquivalence(q, jpql);
     }
-    
-    @AllowFailure
+
+    @AllowFailure(message="AbstractExpressionExecutor.assertNotContainer() not happy")
+    public void testOrdering() {
+        String jpql = "SELECT c FROM Customer c JOIN c.orders o "
+                + "JOIN c.address a WHERE a.state = 'CA' ORDER BY o.quantity DESC, "
+                + "o.totalCost";
+        CriteriaQuery q = cb.create();
+        Root<Customer> c = q.from(Customer.class);
+        Join<Customer, Order> o = c.join(Customer_.orders);
+        Join<Customer, Address> a = c.join(Customer_.address);
+        q.where(cb.equal(a.get(Address_.state), "CA"));
+        q.orderBy(cb.desc(o.get(Order_.quantity)), cb.asc(o
+                .get(Order_.totalCost)));
+        q.select(o);
+
+        assertEquivalence(q, jpql);
+
+        jpql = "SELECT o.quantity, a.zipCode FROM Customer c JOIN c.orders "
+                + "JOIN c.address a WHERE a.state = 'CA' ORDER BY o.quantity, "
+                + "a.zipCode";
+        q = cb.create();
+        Root<Customer> c1 = q.from(Customer.class);
+        Join<Customer, Order> o1 = c1.join(Customer_.orders);
+        Join<Customer, Address> a1 = c1.join(Customer_.address);
+        q.where(cb.equal(a1.get(Address_.state), "CA"));
+        q.orderBy(cb.asc(o1.get(Order_.quantity)), cb.asc(a1
+                .get(Address_.zipCode)));
+        q.select(o1.get(Order_.quantity), a1.get(Address_.zipCode));
+
+        assertEquivalence(q, jpql);
+
+        jpql = "SELECT o.quantity, o.cost * 1.08 AS taxedCost, a.zipCode "
+                + "FROM Customer c JOIN c.orders o JOIN c.address a "
+                + "WHERE a.state = 'CA' AND a.county = 'Santa Clara' "
+                + "ORDER BY o.quantity, taxedCost, a.zipCode";
+        q = cb.create();
+        Root<Customer> c2 = q.from(Customer.class);
+        Join<Customer, Order> o2 = c2.join(Customer_.orders);
+        Join<Customer, Address> a2 = c2.join(Customer_.address);
+        q.where(cb.equal(a.get(Address_.state), "CA"), cb.equal(a
+                .get(Address_.county), "Santa Clara"));
+        q.orderBy(cb.asc(o.get(Order_.quantity)), cb.asc(cb.prod(
+                  o.get(Order_.totalCost), 1.08)), 
+                  cb.asc(a.get(Address_.zipCode)));
+        q.select(o.get(Order_.quantity), cb.prod(
+                 o.get(Order_.totalCost), 1.08), a.get(Address_.zipCode));
+
+        assertEquivalence(q, jpql);
+    }
+
+    @AllowFailure(message="AbstractExpressionExecutor.assertNotContainer() not happy")
     public void testOrdering1() {
-        String jpql = "SELECT o FROM Customer c JOIN c.orders o " + 
-            "JOIN c.address a WHERE a.state = 'CA' ORDER BY o.quantity DESC, " +
-            "o.totalCost";
+        String jpql = "SELECT o FROM Customer c JOIN c.orders o "
+                + "JOIN c.address a WHERE a.state = 'CA' ORDER BY o.quantity DESC, "
+                + "o.totalCost";
         CriteriaQuery q = cb.create();
         Root<Customer> c = q.from(Customer.class);
-        Join<Customer,Order> o = c.join(Customer_.orders);
-        Join<Customer,Address> a = c.join(Customer_.address);
-        q.where(cb.equal(a.get(Address_.state), "CA")); 
-        q.orderBy(cb.desc(o.get(Order_.quantity)), 
-            cb.asc(o.get(Order_.totalCost)));
+        Join<Customer, Order> o = c.join(Customer_.orders);
+        Join<Customer, Address> a = c.join(Customer_.address);
+        q.where(cb.equal(a.get(Address_.state), "CA"));
+        q.orderBy(cb.desc(o.get(Order_.quantity)), cb.asc(o
+                .get(Order_.totalCost)));
         q.select(o);
-        
+
         assertEquivalence(q, jpql);
     }
-    
-    @AllowFailure
+
+    @AllowFailure(message="The JPQL is broken!")
     public void testOrdering2() {
-        String jpql = "SELECT o.quantity, a.zipCode FROM Customer c " + 
-            "JOIN c.orders JOIN c.address a WHERE a.state = 'CA' " + 
-            "ORDER BY o.quantity, a.zipCode";
-        CriteriaQuery q = cb.create();
-        Root<Customer> c = q.from(Customer.class); 
-        Join<Customer,Order> o = c.join(Customer_.orders);
-        Join<Customer,Address> a = c.join(Customer_.address);
+        String jpql = "SELECT o.quantity, a.zipCode FROM Customer c "
+                + "JOIN c.orders JOIN c.address a WHERE a.state = 'CA' "
+                + "ORDER BY o.quantity, a.zipCode";
+        CriteriaQuery q = cb.create();
+        Root<Customer> c = q.from(Customer.class);
+        Join<Customer, Order> o = c.join(Customer_.orders);
+        Join<Customer, Address> a = c.join(Customer_.address);
         q.where(cb.equal(a.get(Address_.state), "CA"));
-        q.orderBy(cb.asc(o.get(Order_.quantity)), cb.asc(a.get(
-            Address_.zipCode)));
+        q.orderBy(cb.asc(o.get(Order_.quantity)), cb.asc(a
+                .get(Address_.zipCode)));
         q.select(o.get(Order_.quantity), a.get(Address_.zipCode));
-        
+
         assertEquivalence(q, jpql);
     }
-    
-    @AllowFailure
+
+    @AllowFailure(message="QueryExpression.ordering not initialized")
     public void testOrdering3() {
-        String jpql = "SELECT o.quantity, o.cost * 1.08 AS taxedCost, " + 
-            "a.zipCode FROM Customer c JOIN c.orders o JOIN c.address a " + 
-            "WHERE a.state = 'CA' AND a.county = 'Santa Clara' " + 
-            "ORDER BY o.quantity, taxedCost, a.zipCode";
-        CriteriaQuery q = cb.create();
-        Root<Customer> c = q.from(Customer.class);
-        Join<Customer,Order> o = c.join(Customer_.orders);
-        Join<Customer,Address> a = c.join(Customer_.address);
-        q.where(cb.equal(a.get(Address_.state), "CA"),
-                cb.equal(a.get(Address_.county), "Santa Clara"));
-        q.orderBy(cb.asc(o.get(Order_.quantity)),
-                cb.asc(cb.prod(o.get(Order_.totalCost), 1.08)),
-                cb.asc(a.get(Address_.zipCode)));
-        q.select(o.get(Order_.quantity), 
-                cb.prod(o.get(Order_.totalCost), 1.08),
-                a.get(Address_.zipCode));
+        String jpql = "SELECT o.quantity, o.totalCost * 1.08 AS taxedCost, "
+                + "a.zipCode FROM Customer c JOIN c.orders o JOIN c.address a "
+                + "WHERE a.state = 'CA' AND a.county = 'Santa Clara' "
+                + "ORDER BY o.quantity, taxedCost, a.zipCode";
+        CriteriaQuery q = cb.create();
+        Root<Customer> c = q.from(Customer.class);
+        Join<Customer, Order> o = c.join(Customer_.orders);
+        Join<Customer, Address> a = c.join(Customer_.address);
+        q.where(cb.equal(a.get(Address_.state), "CA"), cb.equal(a
+                .get(Address_.county), "Santa Clara"));
+        q.orderBy(cb.asc(o.get(Order_.quantity)), cb.asc(cb.prod(
+                  o.get(Order_.totalCost), 1.08)), 
+                  cb.asc(a.get(Address_.zipCode)));
+        q.select(o.get(Order_.quantity), cb.prod(
+                        o.get(Order_.totalCost), 1.08), a.get(Address_.zipCode));
 
         assertEquivalence(q, jpql);
     }
-    
+
+
+    @AllowFailure(message="QueryExpression.ordering not initialized")
     public void testOrdering4() {
         String jpql = "SELECT c FROM Customer c "
                 + "ORDER BY c.name DESC, c.status";
@@ -704,76 +821,17 @@
         assertEquivalence(q, jpql);
     }
 
+    @AllowFailure(message="QueryExpression.ordering not initialized")
     public void testOrdering5() {
-        String jpql = "SELECT c.firstName, c.lastName, c.balanceOwed " + 
-            "FROM Customer c ORDER BY c.name DESC, c.status";
+        String jpql = "SELECT c.firstName, c.lastName, c.balanceOwed "
+                + "FROM Customer c ORDER BY c.name DESC, c.status";
         CriteriaQuery q = cb.create();
         Root<Customer> c = q.from(Customer.class);
         q.orderBy(cb.desc(c.get(Customer_.name)), cb.asc(c
-            .get(Customer_.status)));
-        q.select(c.get(Customer_.firstName), c.get(Customer_.lastName),
-            c.get(Customer_.balanceOwed));
-
-        assertEquivalence(q, jpql);
-    }
-
-    void assertEquivalence(CriteriaQuery c, String jpql, 
-        String[] paramNames, Object[] params) {
-        sql.clear();
-        Query q = em.createQuery(c);
-        for (int i = 0; i < paramNames.length; i++) {
-            q.setParameter(paramNames[i], params[i]);
-        }
-        List cList = q.getResultList();
-        assertEquals(1, sql.size());
-        String cSQL = sql.get(0);
-        
-        sql.clear();
-        q = em.createQuery(jpql);
-        for (int i = 0; i < paramNames.length; i++) {
-            q.setParameter(paramNames[i], params[i]);
-        }
-        List jList = q.getResultList();
-        assertEquals(1, sql.size());
-        String jSQL = sql.get(0);
-        
-        assertEquals(jSQL, cSQL);
-    }
-
-    void assertEquivalence(CriteriaQuery c, String jpql, 
-        Object[] params) {
-        sql.clear();
-        Query q = em.createQuery(c);
-        for (int i = 0; i < params.length; i++) {
-            q.setParameter(i+1, params[i]);
-        }
-        List cList = q.getResultList();
-        assertEquals(1, sql.size());
-        String cSQL = sql.get(0);
-
-        sql.clear();
-        q = em.createQuery(jpql);
-        for (int i = 0; i < params.length; i++) {
-            q.setParameter(i+1, params[i]);
-        }
-        List jList = q.getResultList();
-        assertEquals(1, sql.size());
-        String jSQL = sql.get(0);
-
-        assertEquals(jSQL, cSQL);
-    }
-    
-    void assertEquivalence(CriteriaQuery c, String jpql) {
-    	sql.clear();
-    	List cList = em.createQuery(c).getResultList();
-    	assertEquals(1, sql.size());
-    	String cSQL = sql.get(0);
-    	
-    	sql.clear();
-    	List jList = em.createQuery(jpql).getResultList();
-    	assertEquals(1, sql.size());
-    	String jSQL = sql.get(0);
-    	
-    	assertEquals(jSQL, cSQL);
+                .get(Customer_.status)));
+        q.select(c.get(Customer_.firstName), c.get(Customer_.lastName), c
+                .get(Customer_.balanceOwed));
+
+        assertEquivalence(q, jpql);
     }
 }

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/Transaction_.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/Transaction_.java?rev=776951&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/Transaction_.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/Transaction_.java Thu May 21 05:05:39 2009
@@ -0,0 +1,10 @@
+/** 
+ *  Generated by OpenJPA MetaModel Generator Tool.
+**/
+
+package org.apache.openjpa.persistence.criteria;
+
+
+@javax.persistence.metamodel.TypesafeMetamodel(value=org.apache.openjpa.persistence.criteria.Transaction.class)
+public class Transaction_ {
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/Transaction_.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu May 21 05:05:39 2009
@@ -3,3 +3,4 @@
 bin
 *.log
 maven-eclipse.xml
+*.class

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ArrayMember_.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ArrayMember_.java?rev=776951&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ArrayMember_.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ArrayMember_.java Thu May 21 05:05:39 2009
@@ -0,0 +1,13 @@
+/** 
+ *  Generated by OpenJPA MetaModel Generator Tool.
+**/
+
+package org.apache.openjpa.persistence.meta;
+
+import javax.persistence.metamodel.Attribute;
+
+@javax.persistence.metamodel.TypesafeMetamodel(value=org.apache.openjpa.persistence.meta.ArrayMember.class)
+public class ArrayMember_ {
+    public static volatile Attribute<ArrayMember,Byte[]> Array;
+    public static volatile Attribute<ArrayMember,byte[]> array;
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ArrayMember_.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/Embed0_.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/Embed0_.java?rev=776951&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/Embed0_.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/Embed0_.java Thu May 21 05:05:39 2009
@@ -0,0 +1,13 @@
+/** 
+ *  Generated by OpenJPA MetaModel Generator Tool.
+**/
+
+package org.apache.openjpa.persistence.meta;
+
+import javax.persistence.metamodel.Attribute;
+
+@javax.persistence.metamodel.TypesafeMetamodel(value=org.apache.openjpa.persistence.meta.Embed0.class)
+public class Embed0_ {
+    public static volatile Attribute<Embed0,ImplicitFieldAccessSubclass> entity1;
+    public static volatile Attribute<Embed0,Long> f1;
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/Embed0_.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/Embed1_.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/Embed1_.java?rev=776951&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/Embed1_.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/Embed1_.java Thu May 21 05:05:39 2009
@@ -0,0 +1,13 @@
+/** 
+ *  Generated by OpenJPA MetaModel Generator Tool.
+**/
+
+package org.apache.openjpa.persistence.meta;
+
+import javax.persistence.metamodel.Attribute;
+
+@javax.persistence.metamodel.TypesafeMetamodel(value=org.apache.openjpa.persistence.meta.Embed1.class)
+public class Embed1_ {
+    public static volatile Attribute<Embed1,ImplicitFieldAccessBase> entity0;
+    public static volatile Attribute<Embed1,String> f1;
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/Embed1_.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitFieldAccess.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitFieldAccess.java?rev=776951&r1=776950&r2=776951&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitFieldAccess.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitFieldAccess.java Thu May 21 05:05:39 2009
@@ -22,6 +22,7 @@
 import javax.persistence.Access;
 import javax.persistence.AccessType;
 import javax.persistence.Entity;
+import javax.persistence.OneToOne;
 import javax.persistence.Transient;
 
 /**
@@ -38,7 +39,9 @@
 	private long f1;
 	private int  f2;
 	@Transient private short f3;
+	@OneToOne
 	private ImplicitFieldAccessBase f4;
+	@OneToOne
 	private ImplicitFieldAccessBase f5;
 	private transient ImplicitFieldAccessBase f6;
 	

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitFieldAccessMixed_.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitFieldAccessMixed_.java?rev=776951&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitFieldAccessMixed_.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitFieldAccessMixed_.java Thu May 21 05:05:39 2009
@@ -0,0 +1,15 @@
+/** 
+ *  Generated by OpenJPA MetaModel Generator Tool.
+**/
+
+package org.apache.openjpa.persistence.meta;
+
+import javax.persistence.metamodel.Attribute;
+
+@javax.persistence.metamodel.TypesafeMetamodel(value=org.apache.openjpa.persistence.meta.ExplicitFieldAccessMixed.class)
+public class ExplicitFieldAccessMixed_ {
+    public static volatile Attribute<ExplicitFieldAccessMixed,Long> f1;
+    public static volatile Attribute<ExplicitFieldAccessMixed,Integer> f2;
+    public static volatile Attribute<ExplicitFieldAccessMixed,ImplicitFieldAccessBase> f4;
+    public static volatile Attribute<ExplicitFieldAccessMixed,ImplicitFieldAccessBase> f5;
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitFieldAccessMixed_.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitFieldAccess_.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitFieldAccess_.java?rev=776951&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitFieldAccess_.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitFieldAccess_.java Thu May 21 05:05:39 2009
@@ -0,0 +1,15 @@
+/** 
+ *  Generated by OpenJPA MetaModel Generator Tool.
+**/
+
+package org.apache.openjpa.persistence.meta;
+
+import javax.persistence.metamodel.Attribute;
+
+@javax.persistence.metamodel.TypesafeMetamodel(value=org.apache.openjpa.persistence.meta.ExplicitFieldAccess.class)
+public class ExplicitFieldAccess_ {
+    public static volatile Attribute<ExplicitFieldAccess,Long> f1;
+    public static volatile Attribute<ExplicitFieldAccess,Integer> f2;
+    public static volatile Attribute<ExplicitFieldAccess,ImplicitFieldAccessBase> f4;
+    public static volatile Attribute<ExplicitFieldAccess,ImplicitFieldAccessBase> f5;
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitFieldAccess_.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitPropertyAccessMixed_.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitPropertyAccessMixed_.java?rev=776951&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitPropertyAccessMixed_.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitPropertyAccessMixed_.java Thu May 21 05:05:39 2009
@@ -0,0 +1,16 @@
+/** 
+ *  Generated by OpenJPA MetaModel Generator Tool.
+**/
+
+package org.apache.openjpa.persistence.meta;
+
+import javax.persistence.metamodel.Attribute;
+
+@javax.persistence.metamodel.TypesafeMetamodel(value=org.apache.openjpa.persistence.meta.ExplicitPropertyAccessMixed.class)
+public class ExplicitPropertyAccessMixed_ {
+    public static volatile Attribute<ExplicitPropertyAccessMixed,String> f1;
+    public static volatile Attribute<ExplicitPropertyAccessMixed,ImplicitFieldAccessBase> f3;
+    public static volatile Attribute<ExplicitPropertyAccessMixed,Integer> f4;
+    public static volatile Attribute<ExplicitPropertyAccessMixed,Short> f5;
+    public static volatile Attribute<ExplicitPropertyAccessMixed,ImplicitFieldAccessBase> f6;
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitPropertyAccessMixed_.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitPropertyAccess_.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitPropertyAccess_.java?rev=776951&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitPropertyAccess_.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitPropertyAccess_.java Thu May 21 05:05:39 2009
@@ -0,0 +1,16 @@
+/** 
+ *  Generated by OpenJPA MetaModel Generator Tool.
+**/
+
+package org.apache.openjpa.persistence.meta;
+
+import javax.persistence.metamodel.Attribute;
+
+@javax.persistence.metamodel.TypesafeMetamodel(value=org.apache.openjpa.persistence.meta.ExplicitPropertyAccess.class)
+public class ExplicitPropertyAccess_ {
+    public static volatile Attribute<ExplicitPropertyAccess,String> f1;
+    public static volatile Attribute<ExplicitPropertyAccess,String> f3;
+    public static volatile Attribute<ExplicitPropertyAccess,String> f4;
+    public static volatile Attribute<ExplicitPropertyAccess,ImplicitFieldAccessBase> f5;
+    public static volatile Attribute<ExplicitPropertyAccess,ImplicitFieldAccessBase> f6;
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ExplicitPropertyAccess_.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ImplicitFieldAccessBase_.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ImplicitFieldAccessBase_.java?rev=776951&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ImplicitFieldAccessBase_.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ImplicitFieldAccessBase_.java Thu May 21 05:05:39 2009
@@ -0,0 +1,24 @@
+/** 
+ *  Generated by OpenJPA MetaModel Generator Tool.
+**/
+
+package org.apache.openjpa.persistence.meta;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.Collection;
+import javax.persistence.metamodel.List;
+import javax.persistence.metamodel.Map;
+import javax.persistence.metamodel.Set;
+
+@javax.persistence.metamodel.TypesafeMetamodel(value=org.apache.openjpa.persistence.meta.ImplicitFieldAccessBase.class)
+public class ImplicitFieldAccessBase_ extends ImplicitFieldAccessMappedSuperclass_  {
+    public static volatile Attribute<ImplicitFieldAccessBase,Integer> boxedInt;
+    public static volatile Collection<ImplicitFieldAccessBase,ExplicitFieldAccess> collectionRelation;
+    public static volatile Attribute<ImplicitFieldAccessBase,String> f0;
+    public static volatile List<ImplicitFieldAccessBase,ExplicitFieldAccess> listRelation;
+    public static volatile Map<ImplicitFieldAccessBase,Integer,ExplicitFieldAccess> mapRelationKeyBasic;
+    public static volatile Map<ImplicitFieldAccessBase,ExplicitPropertyAccess,ExplicitFieldAccess> mapRelationKeyPC;
+    public static volatile Attribute<ImplicitFieldAccessBase,ExplicitFieldAccess> one2oneRelation;
+    public static volatile Attribute<ImplicitFieldAccessBase,Integer> primitiveInt;
+    public static volatile Set<ImplicitFieldAccessBase,ExplicitFieldAccess> setRelation;
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ImplicitFieldAccessBase_.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ImplicitFieldAccessMappedSuperclass_.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ImplicitFieldAccessMappedSuperclass_.java?rev=776951&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ImplicitFieldAccessMappedSuperclass_.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ImplicitFieldAccessMappedSuperclass_.java Thu May 21 05:05:39 2009
@@ -0,0 +1,14 @@
+/** 
+ *  Generated by OpenJPA MetaModel Generator Tool.
+**/
+
+package org.apache.openjpa.persistence.meta;
+
+import java.util.Date;
+import javax.persistence.metamodel.Attribute;
+
+@javax.persistence.metamodel.TypesafeMetamodel(value=org.apache.openjpa.persistence.meta.ImplicitFieldAccessMappedSuperclass.class)
+public class ImplicitFieldAccessMappedSuperclass_ {
+    public static volatile Attribute<ImplicitFieldAccessMappedSuperclass,Date> createTime;
+    public static volatile Attribute<ImplicitFieldAccessMappedSuperclass,Long> id;
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ImplicitFieldAccessMappedSuperclass_.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ImplicitFieldAccessSubclass_.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ImplicitFieldAccessSubclass_.java?rev=776951&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ImplicitFieldAccessSubclass_.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ImplicitFieldAccessSubclass_.java Thu May 21 05:05:39 2009
@@ -0,0 +1,14 @@
+/** 
+ *  Generated by OpenJPA MetaModel Generator Tool.
+**/
+
+package org.apache.openjpa.persistence.meta;
+
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.Map;
+
+@javax.persistence.metamodel.TypesafeMetamodel(value=org.apache.openjpa.persistence.meta.ImplicitFieldAccessSubclass.class)
+public class ImplicitFieldAccessSubclass_ extends ImplicitFieldAccessBase_  {
+    public static volatile Attribute<ImplicitFieldAccessSubclass,ImplicitFieldAccessBase> base;
+    public static volatile Map<ImplicitFieldAccessSubclass,Embed0,ExplicitPropertyAccess> mapRelationKeyEmbedded;
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/ImplicitFieldAccessSubclass_.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestMetamodel.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestMetamodel.java?rev=776951&r1=776950&r2=776951&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestMetamodel.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/TestMetamodel.java Thu May 21 05:05:39 2009
@@ -35,8 +35,6 @@
 
 import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.meta.MetaDataRepository;
-import org.apache.openjpa.persistence.criteria.Account;
-import org.apache.openjpa.persistence.criteria.Account_;
 import org.apache.openjpa.persistence.test.SingleEMFTestCase;
 
 /**
@@ -46,12 +44,11 @@
  *
  */
 public class TestMetamodel extends SingleEMFTestCase {
-    MetamodelImpl model;
-    MetaDataRepository repos;
+    private static MetamodelImpl model;
     
     public void setUp() {
+        if (model == null) {
     	super.setUp(
-    	        Account.class,
     			ImplicitFieldAccessMappedSuperclass.class,
     	        ImplicitFieldAccessBase.class, 
     	        ImplicitFieldAccessSubclass.class,
@@ -60,32 +57,38 @@
     	        Embed0.class, 
     	        Embed1.class);
     	emf.createEntityManager();
-    	repos = emf.getConfiguration().getMetaDataRepositoryInstance();
         model = (MetamodelImpl)emf.getMetamodel();
+        }
     }
     
-    public void testModelIsInstantiated() {
+    public void testMetaModelForDomainClassesExist() {
         assertFalse(model.getEntities().isEmpty());
         assertFalse(model.getEmbeddables().isEmpty());
         assertFalse(model.getManagedTypes().isEmpty());
     }
     
-    public void testModelIsPopulated() {
-        Entity<Account> m = model.entity(Account.class);
+    public void testMetaClassFieldsArePopulated() {
+        Entity<ImplicitFieldAccessSubclass> m = 
+            model.entity(ImplicitFieldAccessSubclass.class);
         Class<?> mCls = m.getJavaType();
         assertNotNull(m);
-        Class<?> m2Cls = repos.getMetaModel(mCls, true);
+        assertSame(ImplicitFieldAccessSubclass.class, mCls);
+        
+        Class<?> m2Cls = model.repos.getMetaModel(mCls, true);
         assertNotNull(m2Cls);
         try {
-            Field f2 = getStaticField(m2Cls, "balance");
+            Field f2 = getStaticField(m2Cls, "base");
             assertNotNull(f2);
+            Object value = f2.get(null);
+            assertNotNull(value);
+            assertTrue(Attribute.class.isAssignableFrom(value.getClass()));
         } catch (Throwable t) {
             t.printStackTrace();
             fail();
         }
     }
     
-    public void testPersistentCategory() {
+    public void testDomainClassAreCategorizedInPersistentCategory() {
     	assertCategory(PersistenceType.MAPPED_SUPERCLASS, 
     			ImplicitFieldAccessMappedSuperclass.class);
     	assertCategory(PersistenceType.ENTITY, ImplicitFieldAccessBase.class);
@@ -106,7 +109,7 @@
         		model.type(ImplicitFieldAccessMappedSuperclass.class)));
     }
     
-    public void testAttributeByNameAndType() {
+    public void testGetAttributeByNameAndTypeFromMetaClass() {
         ManagedType<ImplicitFieldAccessBase> e0 = model.entity(
         		ImplicitFieldAccessBase.class);
         assertNotNull(e0.getAttribute("f0"));
@@ -188,11 +191,10 @@
     public void testDeclaredFields() {
         ManagedType<ImplicitFieldAccessSubclass> e1 = 
         	model.entity(ImplicitFieldAccessSubclass.class);
-        java.util.Set all = e1.getAttributes();
-        java.util.Set decl = e1.getDeclaredAttributes();
-        assertTrue(all.size() > decl.size());
-        all.removeAll(decl);
-        System.err.println(all);
+        java.util.Set<?> all = e1.getAttributes();
+        java.util.Set<?> decl = e1.getDeclaredAttributes();
+        assertTrue("All fields " + all + "\r\nDeclared fields " + decl + "\r\n"+
+         "expecetd not all fields as declared", all.size() > decl.size());
     }
     
     public void testNonExistentField() {
@@ -205,32 +207,31 @@
         
     }
     
-    void assertFails(ManagedType type, String name, boolean dec) {
+    void assertFails(ManagedType<?> type, String name, boolean dec) {
         try {
-            Attribute a = dec ? type.getDeclaredAttribute(name) 
+            Attribute<?,?> a = dec ? type.getDeclaredAttribute(name) 
                 : type.getAttribute(name);
             fail("Expected to fail " + name + " on " + type);
         } catch (IllegalArgumentException e) {
-            System.err.println(e);
+            System.err.println("Expeceted:" + e);
         }
     }
     
     
     PersistenceType categorize(Class<?> c) {
-        ClassMetaData meta = model.repos.getCachedMetaData(c);
+        Types.Managed<?> type = (Types.Managed<?>)model.getType(c);
+        ClassMetaData meta = type.meta;
         return MetamodelImpl.getPersistenceType(meta);
     }
     
     void assertCategory(PersistenceType category, Class<?> cls) {
-    	assertEquals(category, categorize(cls));
+    	assertEquals(cls.toString(), category, categorize(cls));
     }
     
     Field getStaticField(Class<?> cls, String name) {
         try {
-            System.err.println("Fields of " + cls);
             Field[] fds = cls.getDeclaredFields();
             for (Field f : fds) {
-                System.err.println(f);
                 int mods = f.getModifiers();
                 if (f.getName().equals(name) && Modifier.isStatic(mods))
                     return f;

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java?rev=776951&r1=776950&r2=776951&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java Thu May 21 05:05:39 2009
@@ -1536,7 +1536,7 @@
     }
 
     public QueryBuilder getQueryBuilder() {
-        return null;
+        return _emf.getQueryBuilder();
     }
 
     public Set<String> getSupportedProperties() {

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ResultItemImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ResultItemImpl.java?rev=776951&r1=776950&r2=776951&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ResultItemImpl.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ResultItemImpl.java Thu May 21 05:05:39 2009
@@ -30,12 +30,14 @@
 public class ResultItemImpl<X> implements ResultItem<X> {
     protected String _alias;
     protected Class<X> _cls;
-    
+    static int i = 0;
     protected ResultItemImpl(Class<X> cls) {
         _cls = cls;
     }
     
     public String getAlias() {
+        if (_alias == null)
+            _alias = "c"+ i++;
         return _alias;
     }
 

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaBuilder.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaBuilder.java?rev=776951&r1=776950&r2=776951&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaBuilder.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaBuilder.java Thu May 21 05:05:39 2009
@@ -86,6 +86,7 @@
 
     public void populate(Object parsed, ExpressionStoreQuery query) {
         CriteriaQueryImpl c = (CriteriaQueryImpl) parsed;
+        query.invalidateCompilation();
         query.getContext().setCandidateType(c.getRoot().getJavaType(), true);
         query.setQuery(parsed);
     }

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaQueryImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaQueryImpl.java?rev=776951&r1=776950&r2=776951&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaQueryImpl.java (original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/criteria/CriteriaQueryImpl.java Thu May 21 05:05:39 2009
@@ -20,6 +20,7 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
@@ -27,6 +28,7 @@
 import javax.persistence.Parameter;
 import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Expression;
+import javax.persistence.criteria.Join;
 import javax.persistence.criteria.Order;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
@@ -42,14 +44,21 @@
 import org.apache.openjpa.kernel.exps.Value;
 import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.meta.FieldMetaData;
+import org.apache.openjpa.persistence.meta.Members;
 import org.apache.openjpa.persistence.meta.MetamodelImpl;
 import org.apache.openjpa.persistence.meta.Types;
 
 /**
  * Criteria query implementation.
  * 
+ * Collects clauses of criteria query (e.g. select projections, from/join, 
+ * where conditions, order by).
+ * Eventually translates these clauses to a similar form of Expression tree
+ * that can be interpreted and executed against a data store by OpenJPA kernel.
+ *   
  * @author Pinaki Poddar
  *
+ * @since 2.0.0
  */
 public class CriteriaQueryImpl implements CriteriaQuery {
     private final MetamodelImpl  _model;
@@ -129,7 +138,7 @@
     }
 
     public <X> Root<X> from(Entity<X> entity) {
-        Root<X> root = new RootImpl<X>(entity);
+        Root<X> root = new RootImpl<X>((Types.Entity<X>)entity);
         if (_roots == null) {
             _roots = new LinkedHashSet<Root<?>>();
         }
@@ -158,8 +167,7 @@
     }
     
     public Root<?> getRoot() {
-        if (_roots == null || _roots.isEmpty())
-            throw new IllegalStateException("no root is set");
+        assertRoot();
         return _roots.iterator().next();
     }
 
@@ -189,26 +197,19 @@
     }
 
     /**
-     * Populate kernel expressions.
+     * Populate a kernel expression tree by translating the components of this
+     * receiver with the help of the given {@link ExpressionFactory}.
      */
     QueryExpressions getQueryExpressions(ExpressionFactory factory) {
 	    QueryExpressions exps = new QueryExpressions();
 	    
-	    if (_roots != null) {
-	    	exps.accessPath = new ClassMetaData[_roots.size()];
-	    	int i = 0;
-	    	for (Root<?> r : _roots)
-	    	   exps.accessPath[i++] = ((Types.Managed<?>)r.getModel()).meta;
-	    }
-	//    exps.alias = null;      // String   
-        exps.distinct = _distinct == null ? QueryExpressions.DISTINCT_FALSE :
-            _distinct ?
-            QueryExpressions.DISTINCT_TRUE | QueryExpressions.DISTINCT_AUTO : 
-            QueryExpressions.DISTINCT_FALSE;
-    //    exps.fetchInnerPaths = null; // String[]
-	//    exps.fetchPaths = null;      // String[]
-	    exps.filter = _where == null ? factory.emptyExpression() 
-	    		: _where.toKernelExpression(factory, _model, this);
+	    evalAccessPaths(exps, factory);
+//    exps.alias = null;      // String   
+	    exps.ascending = new boolean[]{false};
+	    evalDistinct(exps, factory);
+	    evalFetchJoin(exps, factory);
+	    
+	    evalFilter(exps, factory);
 	    
 	    evalGrouping(exps, factory);
 	    exps.having = _having == null ? factory.emptyExpression() 
@@ -217,8 +218,13 @@
 	    evalOrdering(exps, factory);
 	//    exps.operation = QueryOperations.OP_SELECT;
 	    
+
+	//    exps.parameterTypes = null; // LinkedMap<>
+	      evalProjections(exps, factory);
+
 	    evalProjection(exps, factory);
 	    
+
 	//    exps.range = null; // Value[]
 	//    exps.resultClass = null; // Class
 	    if (_parameterTypes != null)
@@ -227,6 +233,15 @@
 	    return exps;
     }
 
+    void evalAccessPaths(QueryExpressions exps, ExpressionFactory factory) {
+        if (_roots != null) {
+            exps.accessPath = new ClassMetaData[_roots.size()];
+            int i = 0;
+            for (Root<?> r : _roots)
+               exps.accessPath[i++] = ((Types.Managed<?>)r.getModel()).meta;
+        }
+    }
+    
     void evalOrdering(QueryExpressions exps, ExpressionFactory factory) {
         if (_orders == null) 
             return;
@@ -249,18 +264,71 @@
     }
     
     void evalGrouping(QueryExpressions exps, ExpressionFactory factory) {
+        //    exps.grouping = null; // Value[]
+        //    exps.groupingClauses = null; // String[]
         if (_groups == null) 
             return;
         int groupByCount = _groups.size();
         exps.grouping = new Value[groupByCount];
-
         for (int i = 0; i < groupByCount; i++) {
              Expression<?> groupBy = _groups.get(i);    
              exps.grouping[i] = Expressions.toValue(
                  (ExpressionImpl<?>)groupBy, factory, _model, this);;
         }
     }
+    
+    void evalProjections(QueryExpressions exps, ExpressionFactory factory) {
+        // TODO: fill in projection aliases and clauses
+        //    exps.projectionAliases = null; // String[]
+        //    exps.projectionClauses = null; // String[]
+    	if (isDefaultProjection()) {
+    	    exps.projections = new Value[0];
+    	    return ;
+    	}
+    	exps.projections = new Value[_selections.size()];
+    	int i = 0;
+    	for (Selection<?> s : _selections) {
+    	    exps.projections[i++] = ((ExpressionImpl<?>)s)
+    	       .toValue(factory, _model, this);
+    	}
+    	return;
+    }
+    
+    boolean isDefaultProjection() {
+        return _selections == null 
+           || (_selections.size() == 1 && _selections.get(0) == getRoot());
+    }
+    
+    void evalDistinct(QueryExpressions exps, ExpressionFactory factory) {
+        if (_distinct == null) {
+            exps.distinct = QueryExpressions.DISTINCT_FALSE;
+        } else if (_distinct) {
+            exps.distinct = QueryExpressions.DISTINCT_TRUE 
+                          | QueryExpressions.DISTINCT_AUTO;
+        }
+        exps.distinct &= ~QueryExpressions.DISTINCT_AUTO;
+    }
 
+    void evalFilter(QueryExpressions exps, ExpressionFactory factory) {
+        assertRoot();
+        org.apache.openjpa.kernel.exps.Expression filter = null;
+        for (Root<?> root : _roots) {
+            if (root.getJoins() != null) {
+                for (Join<?, ?> join : root.getJoins()) {
+                    filter = and(factory, ((ExpressionImpl<?>)join)
+                        .toKernelExpression(factory, _model, this), filter);
+                }
+            }
+        }
+        if (_where != null) {
+            filter = and(factory, _where.toKernelExpression
+                         (factory, _model, this), filter);
+        }
+        if (filter == null) 
+            filter = factory.emptyExpression();
+        exps.filter = filter;
+    }
+    
     void evalProjection(QueryExpressions exps, ExpressionFactory factory) {
         Value [] projs = toValues(exps, factory, getSelectionList());
         if (projs.length == 1 && projs[0] == null)
@@ -287,6 +355,23 @@
     	
     	return result;
     }
+    
+    void evalFetchJoin(QueryExpressions exps, ExpressionFactory factory) {
+    //    exps.fetchInnerPaths = null; // String[]
+    //    exps.fetchPaths = null;      // String[]
+    }
+
+
+    org.apache.openjpa.kernel.exps.Expression and(ExpressionFactory factory,
+            org.apache.openjpa.kernel.exps.Expression e1, 
+            org.apache.openjpa.kernel.exps.Expression e2) {
+        return e1 == null ? e2 : e2 == null ? e1 : factory.and(e1, e2);
+    }
+    
+    void assertRoot() {
+        if (_roots == null || _roots.isEmpty())
+            throw new IllegalStateException("no root is set");
+    }
 
     void setImplicitTypes(Value val1, Value val2, Class<?> expected) {
         Class<?> c1 = (val1 == null ? null : val1.getType());
@@ -353,4 +438,5 @@
         return "jpqlalias" + (++_aliasCount);
     }
     
+
 }



Mime
View raw message