Return-Path: Delivered-To: apmail-cayenne-commits-archive@www.apache.org Received: (qmail 32611 invoked from network); 9 May 2008 08:15:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 May 2008 08:15:39 -0000 Received: (qmail 4037 invoked by uid 500); 9 May 2008 08:15:42 -0000 Delivered-To: apmail-cayenne-commits-archive@cayenne.apache.org Received: (qmail 4011 invoked by uid 500); 9 May 2008 08:15:42 -0000 Mailing-List: contact commits-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list commits@cayenne.apache.org Received: (qmail 4002 invoked by uid 99); 9 May 2008 08:15:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 May 2008 01:15:41 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 May 2008 08:15:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 96B852388A0A; Fri, 9 May 2008 01:15:19 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@cayenne.apache.org From: aadamchik@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080509081519.96B852388A0A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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> databaseTypes = new HashMap>(); public TypesMapping(DatabaseMetaData metaData) throws SQLException {