emacarron / mybatis

Automatically exported from code.google.com/p/mybatis
0 stars 0 forks source link

Why two entries for each column in unmapped column names?? #93

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version of the MyBatis are you using?
3.0.1

Please describe the problem.  Unit tests are best!
I have a type handler registered to convert Timestamp to ISO-8601 string 
format.  It is registered in 
<configuration>
  <typeHandlers>
    <typeHandler javaType="oracle.sql.TIMESTAMP" handler="wb.server.pod.TimestampTypeHandler"/>...

What is the expected output? What do you see instead?
I expect to see something like this: 2010-06-04T12:59:00
instead I see 2010-6-4.12.59. 0. 0

Please provide any additional information below.
In FastResultSetHandler.loadMappedAndUnmappedColumnNames (line 275) it appears 
to add two names for each column. 

        unmappedColumnNames.add(upperColumnName);
        unmappedColumnNames.add(columnName);

In my case both columnName and upperColumnName are in upper case.  So in 
FastResultSetHandler.applyAutomaticMappings the first time the column gets 
handled with my custom TimestampTypeHandler.  The second time it uses a 
StringTypeHandler which overwrites my ISO-8601 formatted date string.

Can you explain why the column names are there once in 'non-upper-cased' 
fashion and again in 'upper-cased' fashion.  It seems to be evaluating each 
column twice for each row.   Secondly, why does it use a StringTypeHandler the 
second time instead of the custom TimestampTypeHandler I defined?

Finally, Is there an easier (more correct / proper) way to specify formatting 
for Timestamp data types?

Thanks,
Ted

Original issue reported on code.google.com by ted.slus...@gmail.com on 31 Aug 2010 at 8:24

GoogleCodeExporter commented 9 years ago
The resultType is a hashmap.  The first time the FastResultSetHandler attempts 
to determine the propertyType - 

  final Class propertyType = metaObject.getSetterType(property);

it comes back as a java.lang.Object and then goes into the UnknownTypeHandler 
to determine the correct type handler based on the typeHandler configuration.  
The second time it determines the propertyType there is now a property in the 
map for that key.  This causes it to return a java.lang.String as the property 
type then it goes into the StringTypeHandler.  I think that is the problem.

So am I doing something incorrect with the hashmap result type?

Original comment by ted.slus...@gmail.com on 31 Aug 2010 at 8:46

GoogleCodeExporter commented 9 years ago
I am also intrigued why the unmappedColumnNames in 
org.apache.ibatis.executor.resultset.FastResultSetHandler:245 contains each 
column twice. Once the way I have specified and then in all upper-case.
I am using mybatis v. 3.0.2

Original comment by perhac.p...@gmail.com on 5 Sep 2011 at 8:45

GoogleCodeExporter commented 9 years ago

Original comment by eduardo.macarron on 11 Sep 2011 at 4:13