根据配置的sql语句,查询语句需要的字段和对应位置,并储存到map中。
/**
* 根据sqlId查询参数及位置
*
* @param sqlId
* @return
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Map getParameterIndexMap(String sqlId) {
ExtendedSqlMapClient extendedSqlMapClient = (ExtendedSqlMapClient) this.getSqlMapClient();
MappedStatement stmt = extendedSqlMapClient.getMappedStatement(sqlId);
BasicParameterMap parameterMap = (BasicParameterMap) stmt.getParameterMap();
ParameterMapping[] ps = parameterMap.getParameterMappings();
String propertyName = null;
int index = 0;
Map map = new HashMap();
for (ParameterMapping p : ps) {
propertyName = p.getPropertyName();
index = parameterMap.getParameterIndex(propertyName);
map.put(index, propertyName);
}
return map;
}