cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrus Adamchik (JIRA)" <>
Subject [JIRA] Created: (CAY-672) Change the logic to get the Java class from ResultSetMetadata
Date Thu, 28 Sep 2006 15:31:49 GMT
Change the logic to get the Java class from ResultSetMetadata 

         Key: CAY-672
     Project: Cayenne
        Type: Improvement

  Components: Cayenne Core Library  
    Versions: 1.2 [STABLE], 3.0, 2.0 [STABLE]    
    Reporter: Andrus Adamchik
 Assigned to: Andrus Adamchik 
     Fix For: 3.0

See this problem here:

It occurs because ColumnDescriptor incorrectly maps the Java type of a result set column via

Index: /Users/andrus/work/cayenne/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/jdbc/
--- /Users/andrus/work/cayenne/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/jdbc/
(revision 449507)
+++ /Users/andrus/work/cayenne/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/jdbc/
(working copy)
@@ -136,9 +136,10 @@
         this.qualifiedColumnName = name;
         this.label = name;
         this.jdbcType = metaData.getColumnType(position);
-        this.javaClass = getDefaultJavaClass(
-                metaData.getColumnDisplaySize(position),
-                metaData.getScale(position));
+        this.javaClass = metaData.getColumnClassName(position);
+//        this.javaClass = getDefaultJavaClass(
+//                metaData.getColumnDisplaySize(position),
+//                metaData.getScale(position));

Replacing it with ResultSetMetadata.getColumnClassName() produces correct result, however
this may break some DataRow assumptions, so probably adding this fix in 1.2 is not a good
idea (although all current unit tests pass with the fix, so this may not be that bad)

Here is a unit test that demonstrates it, using "INT UNSIGNED" MySQL type:

   public void testLong() throws Exception {

        context.performGenericQuery(new SQLTemplate(
                "DROP TABLE LONG_ENTITY"));
                .performGenericQuery(new SQLTemplate(
                        "CREATE TABLE LONG_ENTITY "
                                + "(ID INT NOT NULL, LONG_FIELD INT UNSIGNED NULL, PRIMARY
KEY (ID))"));

        LongEntity test = (LongEntity) context.newObject(LongEntity.class);

        Long i = new Long(Integer.MAX_VALUE + 10l);

        SelectQuery q = new SelectQuery(LongEntity.class);
        LongEntity testRead = (LongEntity) context.performQuery(q).get(0);
        assertEquals(i, testRead.getLongField());

        SQLTemplate q1 = new SQLTemplate(LongEntity.class, "select * from LONG_ENTITY");
        DataRow row = (DataRow) context.performQuery(q1).get(0);
        assertEquals(i, row.get("LONG_FIELD"));


This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message