一、在ibatis中以Map形式返回查询结果
1、在ibatis的配置文件中配置以HashMap返回的resultMap
<resultMap id="MAX_MIN_ID_RESULT" class="java.util.HashMap">
<result property="MAXID"/>
<result property="MINID"/>
</resultMap>
2、在ibatis的配置文件中,配置以此resultMap为返回值的查询
<select id="SELECT_MAX_MIN_ID_RESULT" resultMap="MAX_MIN_ID_RESULT">
<![CDATA[SELECT
MAX(ID) MAXID,
MIN(ID) MINID
from dual
WHERE C.RNUM <=#maxUpdateCount#
]]>
</select>
二、在查询时,直接传入Map作为参数
public void updateLog(CreateVo vo) throws RepositoryException{
AssertUtils.notNull(vo.getId(), "Id is null");
Map<String,Object> params = new HashMap<String,Object>();
params.put("id", vo.getId());
params.put("modified", vo.getModified());
params.put("deleted", false);
this.update(VisitLogEntity.class,params,"EXT");
}
3、在java代码中调用
getSqlMapClientTemplate().queryForList(statementName,parameterObject); //aegean
List<Object> result = getInfrastructure().getBaseDaoCaesar()
.getObjList(TAG_INSTANCE_NAMESPACE, param,
SELECT_MAX_MIN_ID_RESULT);