Skip to content

Conversation

@kazuki43zoo
Copy link
Member

@kazuki43zoo kazuki43zoo commented Jun 11, 2017

I've fixed gh-1030.
In current implementation, mybatis use the field type of ParamMap#size(HashMap#size) instead of method argument type.

Please review this.

@harawata
Copy link
Member

There is a corner case that tha statement takes HashMap as a parameter.

@Insert("insert into param_test (id, size) values(#{id}, #{size})")
void insertHashMap(HashMap<String, Object> param);

I haven't had the time to test this, but I was going to fix it in SqlSourceBuilder actually.
Something like this.

         propertyType = parameterType;
       } else if (JdbcType.CURSOR.name().equals(propertiesMap.get("jdbcType"))) {
         propertyType = java.sql.ResultSet.class;
-      } else if (property != null) {
+      } else if (property == null || Map.class.isAssignableFrom(parameterType)) {
+        propertyType = Object.class;
+      } else {
         MetaClass metaClass = MetaClass.forClass(parameterType, configuration.getReflectorFactory());
         if (metaClass.hasGetter(property)) {
           propertyType = metaClass.getGetterType(property);
         } else {
           propertyType = Object.class;
         }
-      } else {
-        propertyType = Object.class;
       }
       ParameterMapping.Builder builder = new ParameterMapping.Builder(configuration, property, propertyType);
       Class<?> javaType = propertyType;

@kazuki43zoo
Copy link
Member Author

@harawata Thanks. I agree with your comments. I will update this PR.

@kazuki43zoo kazuki43zoo changed the title Allow long type on size parameter when use the @Param gh-1030 Allow long type on size parameter when use multiple '@Param' Jun 11, 2017
@kazuki43zoo
Copy link
Member Author

I've updated this.

Please review again.

@harawata
Copy link
Member

Looks good. Thank you @kazuki43zoo !

@kazuki43zoo kazuki43zoo merged commit 3aae5f3 into mybatis:master Jun 11, 2017
@kazuki43zoo kazuki43zoo deleted the gh-1030 branch June 11, 2017 14:27
@kazuki43zoo kazuki43zoo self-assigned this Jul 30, 2017
@kazuki43zoo kazuki43zoo added this to the 3.4.5 milestone Jul 30, 2017
pulllock pushed a commit to pulllock/mybatis-3 that referenced this pull request Oct 19, 2023
Allow long type on size parameter when use multiple '@param'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When the parameter name is "size", it is always mapped with integer

2 participants