openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fa...@apache.org
Subject svn commit: r901295 - in /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence: criteria/ detachment/ detachment/model/
Date Wed, 20 Jan 2010 17:34:00 GMT
Author: fancy
Date: Wed Jan 20 17:33:59 2010
New Revision: 901295

URL: http://svn.apache.org/viewvc?rev=901295&view=rev
Log:
OPENJPA-1466 Fix Junit test failures on Oracle

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/criteria/TestTypesafeCriteria.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetachNoStateField.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/NoDetachedStateEntityFieldAccess.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/NoDetachedStateEntityPropertyAccess.java

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=901295&r1=901294&r2=901295&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
Wed Jan 20 17:33:59 2010
@@ -19,23 +19,20 @@
 package org.apache.openjpa.persistence.criteria;
 
 import java.math.BigDecimal;
+import java.sql.Date;
 import java.sql.Time;
+import java.sql.Timestamp;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import javax.persistence.Parameter;
 import javax.persistence.Query;
 import javax.persistence.Tuple;
 import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
 import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Expression;
-import javax.persistence.criteria.Fetch;
 import javax.persistence.criteria.Join;
 import javax.persistence.criteria.JoinType;
 import javax.persistence.criteria.ListJoin;
@@ -49,6 +46,7 @@
 import javax.persistence.metamodel.EntityType;
 import javax.persistence.metamodel.Metamodel;
 
+import org.apache.openjpa.jdbc.sql.OracleDictionary;
 import org.apache.openjpa.persistence.test.AllowFailure;
 
 /**
@@ -1463,8 +1461,12 @@
 
        List result = q.getResultList();        
     }
-    
+
     public void testCurrentTimeReturnsSQLTypes() {
+        if (getDictionary() instanceof OracleDictionary) {
+            // Oracle does not have CURRENT_TIME function, nor does it support DB generated
identity
+            return;
+        }
         em.getTransaction().begin();
         Product pc = new Product();
         em.persist(pc);
@@ -1481,6 +1483,44 @@
         Object result = tq.getSingleResult();
         assertTrue(result.getClass() + " not instance of Time", result instanceof Time);
 
         
+    }    
+
+    public void testCurrentDateReturnsSQLTypes() {
+        em.getTransaction().begin();
+        Order pc = new Order();
+        em.persist(pc);
+        em.getTransaction().commit();
+        
+        int oid = pc.getId();
+        
+        CriteriaQuery<Date> cquery = cb.createQuery(Date.class);
+        Root<Order> order = cquery.from(Order.class);
+        cquery.select(cb.currentDate());
+        cquery.where(cb.equal(order.get(Order_.id), oid));
+
+        TypedQuery<Date> tq = em.createQuery(cquery);
+        Object result = tq.getSingleResult();
+        assertTrue(result.getClass() + " not instance of Date", result instanceof Date);
 
+
+    }
+
+    public void testCurrentTimestampReturnsSQLTypes() {
+        em.getTransaction().begin();
+        Order pc = new Order();
+        em.persist(pc);
+        em.getTransaction().commit();
+
+        int oid = pc.getId();
+
+        CriteriaQuery<Timestamp> cquery = cb.createQuery(Timestamp.class);
+        Root<Order> order = cquery.from(Order.class);
+        cquery.select(cb.currentTimestamp());
+        cquery.where(cb.equal(order.get(Order_.id), oid));
+
+        TypedQuery<Timestamp> tq = em.createQuery(cquery);
+        Object result = tq.getSingleResult();
+        assertTrue(result.getClass() + " not instance of Timestamp", result instanceof Timestamp);
 
+        
     }
     
 //    public void testInMemoryAccessPath() {

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetachNoStateField.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetachNoStateField.java?rev=901295&r1=901294&r2=901295&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetachNoStateField.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/TestDetachNoStateField.java
Wed Jan 20 17:33:59 2010
@@ -28,7 +28,7 @@
 
     @Override
     protected void setUp(Object... props) {
-        super.setUp(CLEAR_TABLES, "openjpa.DetachState", "loaded(DetachedStateField=false)",
+        super.setUp(DROP_TABLES, "openjpa.DetachState", "loaded(DetachedStateField=false)",
             NoDetachedStateEntityPropertyAccess.class, NoDetachedStateEntityFieldAccess.class);
         loadDB();
     }
@@ -78,9 +78,9 @@
     void loadDB() {
         OpenJPAEntityManagerSPI em = emf.createEntityManager();
         em.getTransaction().begin();
-        em.createNativeQuery("INSERT INTO NoDetachedStateEntityPropertyAccess (ID,VERSION)
VALUES (1,0)")
+        em.createNativeQuery("INSERT INTO PropertyAccessNoDetachedState (ID,VERSION) VALUES
(1,0)")
             .executeUpdate();
-        em.createNativeQuery("INSERT INTO NoDetachedStateEntityFieldAccess (ID,VERSION) VALUES
(1,0)")
+        em.createNativeQuery("INSERT INTO FieldAccessNoDetachedState (ID,VERSION) VALUES
(1,0)")
             .executeUpdate();
         em.getTransaction().commit();
         em.close();

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/NoDetachedStateEntityFieldAccess.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/NoDetachedStateEntityFieldAccess.java?rev=901295&r1=901294&r2=901295&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/NoDetachedStateEntityFieldAccess.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/NoDetachedStateEntityFieldAccess.java
Wed Jan 20 17:33:59 2010
@@ -24,9 +24,11 @@
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.ManyToOne;
+import javax.persistence.Table;
 import javax.persistence.Version;
 
 @Entity
+@Table(name="FieldAccessNoDetachedState")
 public class NoDetachedStateEntityFieldAccess {
 	@Id
 	@GeneratedValue(strategy=GenerationType.AUTO)

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/NoDetachedStateEntityPropertyAccess.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/NoDetachedStateEntityPropertyAccess.java?rev=901295&r1=901294&r2=901295&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/NoDetachedStateEntityPropertyAccess.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/detachment/model/NoDetachedStateEntityPropertyAccess.java
Wed Jan 20 17:33:59 2010
@@ -23,9 +23,11 @@
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
+import javax.persistence.Table;
 import javax.persistence.Version;
 
 @Entity
+@Table(name="PropertyAccessNoDetachedState")
 public class NoDetachedStateEntityPropertyAccess {
 	int id;
 	int version;



Mime
View raw message