cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r654715 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/TypesMapping.java
Date Fri, 09 May 2008 08:15:19 GMT
Author: aadamchik
Date: Fri May  9 01:15:19 2008
New Revision: 654715

URL: http://svn.apache.org/viewvc?rev=654715&view=rev
Log:
CAY-1052 related comments. No code changes

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/TypesMapping.java

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=654715&r1=654714&r2=654715&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
Fri May  9 01:15:19 2008
@@ -412,7 +412,7 @@
                 return Types.VARBINARY;
             }
         }
-        
+
         if (Calendar.class.isAssignableFrom(javaClass)) {
             return Types.TIMESTAMP;
         }
@@ -429,7 +429,10 @@
     }
 
     /**
-     * Get the corresponding Java type by its java.sql.Types counterpart.
+     * Get the corresponding Java type by its java.sql.Types counterpart. Note that this
+     * method should be used as a last resort, with explicit mapping provided by user used
+     * as a first choice, as it can only guess how to map certain types, such as NUMERIC,
+     * etc.
      * 
      * @return Fully qualified Java type name or null if not found.
      */
@@ -438,22 +441,25 @@
     }
 
     /**
-     * Get the corresponding Java type by its java.sql.Types counterpart.
+     * Get the corresponding Java type by its java.sql.Types counterpart. Note that this
+     * method should be used as a last resort, with explicit mapping provided by user used
+     * as a first choice, as it can only guess how to map certain types, such as NUMERIC,
+     * etc.
      * 
      * @return Fully qualified Java type name or null if not found.
      */
     public static String getJavaBySqlType(int type, int length, int scale) {
 
+        // 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;
         }
+
         return sqlEnumJava.get(Integer.valueOf(type));
     }
 
-    // *************************************************************
-    // non-static code
-    // *************************************************************
-
     protected Map<Integer, List<TypeInfo>> databaseTypes = new HashMap<Integer,
List<TypeInfo>>();
 
     public TypesMapping(DatabaseMetaData metaData) throws SQLException {



Mime
View raw message