openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r814105 - in /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/results: Order.java TestTypedResults.java
Date Sat, 12 Sep 2009 02:49:29 GMT
Author: ppoddar
Date: Sat Sep 12 02:49:29 2009
New Revision: 814105

URL: http://svn.apache.org/viewvc?rev=814105&view=rev
Log:
Failed Oracle test on bad column name 'date'.

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/results/Order.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/results/TestTypedResults.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/results/Order.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/results/Order.java?rev=814105&r1=814104&r2=814105&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/results/Order.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/results/Order.java
Sat Sep 12 02:49:29 2009
@@ -23,6 +23,7 @@
 import java.util.Set;
 
 import javax.persistence.CascadeType;
+import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.Id;
 import javax.persistence.ManyToOne;
@@ -35,6 +36,7 @@
     @Id
     long id;
     boolean filled;
+    @Column(name="CDATE")
     Date date;
 
     @OneToMany(cascade=CascadeType.PERSIST)

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/results/TestTypedResults.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/results/TestTypedResults.java?rev=814105&r1=814104&r2=814105&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/results/TestTypedResults.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/results/TestTypedResults.java
Sat Sep 12 02:49:29 2009
@@ -21,6 +21,7 @@
 
 import java.text.DateFormat;
 import java.text.ParseException;
+import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
 
@@ -140,28 +141,29 @@
      */
     public void testDateQuery() throws Exception {
         EntityManager em = emf.createEntityManager();
-
+        Date maxDate = df.parse(ORDER_DATES[2]);
+        
         Query jpqlQuery = em.createQuery("Select o from Order o where o.date < :maxDate");
-        jpqlQuery.setParameter("maxDate", df.parse(ORDER_DATES[2]));
+        jpqlQuery.setParameter("maxDate", maxDate);
         List<Order> jpqlResults = jpqlQuery.getResultList();
         assertEquals(N_ORDERS / 2, jpqlResults.size());
 
         TypedQuery<Order> typedJpqlQuery = em.createQuery("Select o from Order o where
o.date < :maxDate", Order.class);
-        typedJpqlQuery.setParameter("maxDate", df.parse(ORDER_DATES[2]));
+        typedJpqlQuery.setParameter("maxDate", maxDate);
         List<Order> typedJpqlResults = typedJpqlQuery.getResultList();
         assertEquals(N_ORDERS / 2, typedJpqlResults.size());
 
         QueryBuilder qb = em.getQueryBuilder();
         CriteriaQuery<Order> criteriaQuery = qb.createQuery(Order.class);
         Root<Order> order = criteriaQuery.from(Order.class);
-        criteriaQuery.select(order).where(qb.lessThan(order.get(Order_.date), df.parse(ORDER_DATES[2])));
+        criteriaQuery.select(order).where(qb.lessThan(order.get(Order_.date), qb.parameter(Date.class,
"maxDate")));
         TypedQuery<Order> tq = em.createQuery(criteriaQuery);
+        tq.setParameter("maxDate", maxDate);
         List<Order> criteriaResults = tq.getResultList();
         assertEquals(N_ORDERS / 2, criteriaResults.size());
 
-        String parm = new java.sql.Timestamp(df.parse(ORDER_DATES[2]).getTime()).toString();
-        Query nativeQuery =
-            em.createNativeQuery("Select * from CRIT_RES_ORD o WHERE (o.date < '" + parm
+ "')", Order.class);
+        Query nativeQuery = em.createNativeQuery("Select * from CRIT_RES_ORD o WHERE (o.cdate
< ?1)", Order.class);
+        nativeQuery.setParameter(1, maxDate);
         List<Order> nativeResults = nativeQuery.getResultList();
         assertEquals(N_ORDERS / 2, nativeResults.size());
 



Mime
View raw message