[jira] Updated: (CAY-672) Change the logic to get the Java class from ResultSetMetadata

From: Andrus Adamchik (JIRA) ("Andrus)
Date: Fri May 09 2008 - 04:27:52 EDT

  • Next message: Andrus Adamchik (JIRA): "[jira] Created: (CAY-1053) MapQueryCache.CacheEntry not serializable"

         [ https://issues.apache.org/cayenne/browse/CAY-672?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

    Andrus Adamchik updated CAY-672:
    --------------------------------

        Fix Version/s: 2.0 [STABLE]
                       1.2 [STABLE]

    > Change the logic to get the Java class from ResultSetMetadata
    > -------------------------------------------------------------
    >
    > Key: CAY-672
    > URL: https://issues.apache.org/cayenne/browse/CAY-672
    > Project: Cayenne
    > Issue Type: Improvement
    > Components: Cayenne Core Library
    > Affects Versions: 1.2 [STABLE], 2.0 [STABLE], 3.0
    > Reporter: Andrus Adamchik
    > Fix For: 1.2 [STABLE], 2.0 [STABLE], 3.0
    >
    >
    > See this problem here:
    > http://objectstyle.org/cayenne/lists/cayenne-user/2006/09/0142.html
    > It occurs because ColumnDescriptor incorrectly maps the Java type of a result set column via "TypesMapping.getJavaBySqlType":
    > Index: /Users/andrus/work/cayenne/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/jdbc/ColumnDescriptor.java
    > ===================================================================
    > --- /Users/andrus/work/cayenne/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/jdbc/ColumnDescriptor.java (revision 449507)
    > +++ /Users/andrus/work/cayenne/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/jdbc/ColumnDescriptor.java (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(
    > LongEntity.class,
    > "DROP TABLE LONG_ENTITY"));
    > context
    > .performGenericQuery(new SQLTemplate(
    > LongEntity.class,
    > "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);
    > test.setLongField(i);
    > context.commitChanges();
    > SelectQuery q = new SelectQuery(LongEntity.class);
    > LongEntity testRead = (LongEntity) context.performQuery(q).get(0);
    > assertNotNull(testRead.getLongField());
    > assertEquals(i, testRead.getLongField());
    > SQLTemplate q1 = new SQLTemplate(LongEntity.class, "select * from LONG_ENTITY");
    > q1.setFetchingDataRows(true);
    > DataRow row = (DataRow) context.performQuery(q1).get(0);
    > assertEquals(i, row.get("LONG_FIELD"));
    > test.setLongField(null);
    > context.commitChanges();
    > }

    -- 
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.
    



    This archive was generated by hypermail 2.0.0 : Fri May 09 2008 - 04:28:25 EDT