Issue 11418

Upgrade mybatis dependency to 3.1.x from 3.0.6

11418
Reporter: trobertson
Type: Task
Summary: Upgrade mybatis dependency to 3.1.x from 3.0.6
Priority: Major
Resolution: Fixed
Status: Closed
Created: 2012-06-13 15:26:08.502
Updated: 2013-12-16 17:50:26.761
Resolved: 2012-08-14 14:10:17.762
        
Description: IT fail in the persistence project when using mybatis 3.1.1

Currently the project downgrades from the gbif-common-batis to 3.0.6 explicitly

### Error updating database.  Cause: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: org.apache.ibatis.binding.BindingException: Parameter 'id' not found. Available parameters are [param1, param2, component, uuid]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: INSERT INTO identifier (identifier, source, agent_id, created, modified,       identifier_type, deleted) (SELECT ?,       ?, a.id, ?,       ?, ?,       ? FROM agent a WHERE a.uuid= ?)
### Cause: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: org.apache.ibatis.binding.BindingException: Parameter 'id' not found. Available parameters are [param1, param2, component, uuid]
	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
]]>
    


Author: monolithic
Created: 2012-07-16 11:46:50.275
Updated: 2012-07-16 11:46:50.275
        
I found the same problem after the version mybatis 3.1.0+

When using DAO, it works fine.
When using mapper, use map as the parameter  ex:  public List listPage(@Param("params")Map params) ;
Then mybatis will call "getParam" method in the class "org.apache.ibatis.binding.MapperMethod"
In version before 3.0.6
code:Map param = new HashMap();
In version after 3.1.0
code:Map param = new MapperParamMap();
and the method :
public static class MapperParamMap extends HashMap {

    private static final long serialVersionUID = -2212268410512043556L;

    @Override
    public V get(Object key) {
      if (!super.containsKey(key)) {
        throw new BindingException("Parameter '" + key + "' not found. Available parameters are " + this.keySet());
      }
      return super.get(key);
    }

  }

So in the sql:
select * from AAA where type='3'