cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r439469 - in /incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src: main/java/org/apache/cayenne/dba/TypesMapping.java test/java/org/apache/cayenne/dba/TypesMappingTst.java
Date Fri, 01 Sep 2006 20:44:42 GMT
Author: aadamchik
Date: Fri Sep  1 13:44:41 2006
New Revision: 439469

URL: http://svn.apache.org/viewvc?rev=439469&view=rev
Log:
CAY-645 - creating default mapping for the calendar type

Modified:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/dba/TypesMapping.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/dba/TypesMappingTst.java

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/dba/TypesMapping.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/dba/TypesMapping.java?rev=439469&r1=439468&r2=439469&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/dba/TypesMapping.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/dba/TypesMapping.java
Fri Sep  1 13:44:41 2006
@@ -24,6 +24,7 @@
 import java.sql.SQLException;
 import java.sql.Types;
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -361,6 +362,15 @@
      * @since 1.1
      */
     public static int getSqlTypeByJava(Class javaClass) {
+        if(javaClass == null) {
+            return NOT_DEFINED;
+        }
+        
+        // check non-standard types
+        if(Calendar.class.isAssignableFrom(javaClass)) {
+            return Types.TIMESTAMP;
+        }
+        
         while (javaClass != null) {
 
             String name;

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/dba/TypesMappingTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/dba/TypesMappingTst.java?rev=439469&r1=439468&r2=439469&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/dba/TypesMappingTst.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/dba/TypesMappingTst.java
Fri Sep  1 13:44:41 2006
@@ -23,6 +23,8 @@
 import java.sql.DatabaseMetaData;
 import java.sql.ResultSet;
 import java.sql.Types;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
 import java.util.Iterator;
 import java.util.List;
 
@@ -35,6 +37,9 @@
 
         // make sure we can handle arrays...
         assertEquals(Types.BINARY, TypesMapping.getSqlTypeByJava(byte[].class));
+        
+        assertEquals(Types.TIMESTAMP, TypesMapping.getSqlTypeByJava(Calendar.class));
+        assertEquals(Types.TIMESTAMP, TypesMapping.getSqlTypeByJava(GregorianCalendar.class));
     }
     
     public void testGetSqlTypeByJavaPrimitive() throws Exception {



Mime
View raw message