openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curti...@apache.org
Subject svn commit: r820051 - in /openjpa/branches/1.3.x: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persiste...
Date Tue, 29 Sep 2009 18:12:47 GMT
Author: curtisr7
Date: Tue Sep 29 18:12:47 2009
New Revision: 820051

URL: http://svn.apache.org/viewvc?rev=820051&view=rev
Log:
OPENJPA-1224. Updated DBDictionary and AbstractDB2Dictionary to properly support java.math.BigDecimal.

Modified:
    openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractDB2Dictionary.java
    openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/SQLBigDecimalIdEntity.java
    openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestSQLBigDecimalId.java
    openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/subquery/TestJPQLSubquery.java

Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractDB2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractDB2Dictionary.java?rev=820051&r1=820050&r2=820051&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractDB2Dictionary.java
(original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractDB2Dictionary.java
Tue Sep 29 18:12:47 2009
@@ -29,7 +29,6 @@
     public int varcharCastLength = 1000;
 
     public AbstractDB2Dictionary() {
-        numericTypeName = "DOUBLE";
         bitTypeName = "SMALLINT";
         smallintTypeName = "SMALLINT";
         tinyintTypeName = "SMALLINT";

Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=820051&r1=820050&r2=820051&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Tue Sep 29 18:12:47 2009
@@ -381,7 +381,7 @@
     public DBDictionary() {
         fixedSizeTypeNameSet.addAll(Arrays.asList(new String[]{
             "BIGINT", "BIT", "BLOB", "CLOB", "DATE", "DECIMAL", "DISTINCT",
-            "DOUBLE", "FLOAT", "INTEGER", "JAVA_OBJECT", "NULL", "NUMERIC",
+            "DOUBLE", "FLOAT", "INTEGER", "JAVA_OBJECT", "NULL", 
             "OTHER", "REAL", "REF", "SMALLINT", "STRUCT", "TIME", "TIMESTAMP",
             "TINYINT",
         }));

Modified: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/SQLBigDecimalIdEntity.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/SQLBigDecimalIdEntity.java?rev=820051&r1=820050&r2=820051&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/SQLBigDecimalIdEntity.java
(original)
+++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/SQLBigDecimalIdEntity.java
Tue Sep 29 18:12:47 2009
@@ -19,6 +19,8 @@
 package org.apache.openjpa.persistence.identity;
 
 import java.math.BigDecimal;
+
+import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.Id;
 
@@ -29,6 +31,7 @@
 public class SQLBigDecimalIdEntity {
 
     @Id
+    @Column(precision=15)
     private BigDecimal id;
     private int data;
 

Modified: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestSQLBigDecimalId.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestSQLBigDecimalId.java?rev=820051&r1=820050&r2=820051&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestSQLBigDecimalId.java
(original)
+++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/identity/TestSQLBigDecimalId.java
Tue Sep 29 18:12:47 2009
@@ -19,9 +19,11 @@
 package org.apache.openjpa.persistence.identity;
 
 import java.math.BigDecimal;
+
 import javax.persistence.EntityManager;
 
 import junit.textui.TestRunner;
+
 import org.apache.openjpa.persistence.test.SingleEMFTestCase;
 
 /**
@@ -54,7 +56,28 @@
         assertEquals(1, e.getData());
         em.close();
     }
+    
+    public void testQuery() {
+        int data = 156;
+        BigDecimal decimal = new BigDecimal(1234);
+        SQLBigDecimalIdEntity e = new SQLBigDecimalIdEntity();
+        e.setId(decimal);
+        e.setData(data);
+
+        EntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+        em.persist(e);
+        em.getTransaction().commit();
 
+        SQLBigDecimalIdEntity e2 =
+            (SQLBigDecimalIdEntity) em.createQuery("SELECT a FROM SQLBigDecimalIdEntity a
WHERE a.data=" + data)
+                .getSingleResult();
+        
+        // This would fail prior to OPENJPA-1224.
+        assertEquals(e, e2);
+        em.close();
+
+    }
     public static void main(String[] args) {
         TestRunner.run(SQLBigDecimalIdEntity.class);
     }

Modified: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/subquery/TestJPQLSubquery.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/subquery/TestJPQLSubquery.java?rev=820051&r1=820050&r2=820051&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/subquery/TestJPQLSubquery.java
(original)
+++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/subquery/TestJPQLSubquery.java
Tue Sep 29 18:12:47 2009
@@ -112,7 +112,7 @@
             "LEFT OUTER JOIN CR_EMP t8 ON t0.SPOUSE_EMPID = t8.empId " +
             "LEFT OUTER JOIN CompUser t3 ON t2.id = t3.ADD_ID " +
             "LEFT OUTER JOIN CR_DEPT t7 ON t6.DEPARTMENT_DEPTNO = t7.deptNo " +
-            "WHERE (CAST(t0.salary AS DOUBLE) > ALL (SELECT t1.salary " +
+            "WHERE (CAST(t0.salary AS NUMERIC) > ALL (SELECT t1.salary " +
             "FROM CR_MGR t1 WHERE (t1.DEPARTMENT_DEPTNO = t0.DEPARTMENT_DEPTNO)))";
         executeAndCompareSQL(jpql, expectedSQL);
     }



Mime
View raw message