<resultMap id="test" class="yourClass">
    <result property="count" column="count"/>
    <result property="age" column="age"/>
</resultMap><statement id="doyourself" resultMap="test">
select count(0) as count ,age from user group by age
</statement>
====================================================
随手写的,没验证是否正确,你试试吧:)

解决方案 »

  1.   

    因为数据库中没有这个count字段,我在我的实体中加了一个Integer类型的count参数,按你这样写了,运行时报错:
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlMapClient' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is com.ibatis.common.exception.NestedRuntimeException: Error occurred.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMap/resultMap/result'.  Cause: com.ibatis.common.beans.ProbeException: There is no WRITEABLE property named 'count' in class 'com.haoxi.framework.sh.sample.entity.User'