cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From and...@apache.org
Subject svn commit: r815288 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/
Date Tue, 15 Sep 2009 12:18:21 GMT
Author: andrey
Date: Tue Sep 15 12:18:20 2009
New Revision: 815288

URL: http://svn.apache.org/viewvc?rev=815288&view=rev
Log:
CAY-1259 Wrong Mapping for NUMERIC Type (based on patch by Evgeny Ryabitskiy)

Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/TypesMapping.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/TypesMappingTest.java

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=815288&r1=815287&r2=815288&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Tue Sep 15 12:18:20 2009
@@ -44,6 +44,7 @@
 CAY-1248 ClassCastException with OracleLOBBatchAction
 CAY-1250 Prefetching doesn't work with prefetched subentity
 CAY-1252 Bad XML generated when saving DBEntity qualifiers
+CAY-1259 Wrong Mapping for NUMERIC Type
 CAY-1265 error while search inheritance relationship
 CAY-1274 CreateTableToDb should not create existing AUTO_PK_SUPPORT
 CAY-1275 Merge set-not-null to Oracle through modeler fails if auto adapter is set

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/TypesMapping.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/TypesMapping.java?rev=815288&r1=815287&r2=815288&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/TypesMapping.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/TypesMapping.java
Tue Sep 15 12:18:20 2009
@@ -452,8 +452,14 @@
         // this does not always produce the correct result. See for instance CAY-1052 - PG
         // drivers from 8.2 and newer decided that the scale of "0" means "undefined", not
         // really zero.
-        if (type == Types.NUMERIC && scale == 0) {
-            type = Types.INTEGER;
+        if (type == Types.NUMERIC && scale == 0) { //SQL integer's max value is 2^31-1,
which has length of 10 
+            if (length < 10) {
+                type = Types.INTEGER;
+            }
+            else if (length < 19) { //SQL's BIGINT max value is 2^63-1, which has length
of 19
+                type = Types.BIGINT;
+            }
+            
         }
 
         return sqlEnumJava.get(Integer.valueOf(type));

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/TypesMappingTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/TypesMappingTest.java?rev=815288&r1=815287&r2=815288&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/TypesMappingTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/TypesMappingTest.java
Tue Sep 15 12:18:20 2009
@@ -71,6 +71,13 @@
         assertEquals(Types.INTEGER, TypesMapping.getSqlTypeByJava(Integer.TYPE));
         assertEquals(Types.BIGINT, TypesMapping.getSqlTypeByJava(Long.TYPE));
     }
+    
+    public void testGetJavaBySqlType() {
+        assertEquals(TypesMapping.JAVA_INTEGER, TypesMapping.getJavaBySqlType(Types.NUMERIC,
5, 0));
+        assertEquals(TypesMapping.JAVA_LONG, TypesMapping.getJavaBySqlType(Types.NUMERIC,
15, 0));
+        assertEquals(TypesMapping.JAVA_BIGDECIMAL, TypesMapping.getJavaBySqlType(Types.NUMERIC,
25, 0));
+        assertEquals(TypesMapping.JAVA_BIGDECIMAL, TypesMapping.getJavaBySqlType(Types.NUMERIC,
25, 5));
+    }
 
     public void testTypeInfoCompleteness() throws Exception {
         // check counts



Mime
View raw message