Ibaits组合查询
麻烦各位大侠帮下忙。
<typeAlias alias="vipmanages" type="com.tsing.xfcl.vo.VipManage"/>
<typeAlias alias="letterbaseinfo" type="com.tsing.xfcl.vo.LetterBaseInfo"/>
<typeAlias alias="lettersinfo" type="com.tsing.xfcl.vo.LettersInFo"/>
<resultMap class="lettersinfo" id="lettersinfoMap">
<result property="idf" column="idf"/>
<result property="letterbaseinfo" column="letterbaseinfo"/>
<result property="letternamef" column="letternamef"/>
<result property="cardtypef" column="cardtypef" />
<result property="cardtypenmf" column="cardtypenmf"/>
<result property="lettercardnof" column="lettercardnof"/>
<result property="lettermobilef" column="lettermobilef"/>
<result property="letterlinkdeptf" column="letterlinkdeptf" />
<result property="letterpostnof" column="letterpostnof"/>
<result property="letteraddressf" column="letteraddressf"/>
<result property="letteradspostnof" column="letteradspostnof"/>
<result property="letterhomeaddrf" column="letterhomeaddrf" />
<result property="letteroriregadsf" column="letteroriregadsf"/>
<result property="letterdcnmf" column="letterdcnmf"/>
<result property="isvipf" column="isvipf"/>
<result property="vipmanages" column="vipmanages" />
</resultMap>
<select id="selectTransacted" resultClass="java.util.HashMap" parameterClass="lettersinfo">
<![CDATA[
select lb.LETTERSOURCE ,li.LETTERNAMEF ,lb.LETTERTITLE ,n.nodename
from lettersinfo li left join letterbaseinfo lb on li.letterbaseinfeoid= lb.idf
left join approveinfo a on a.letterid =li.idf
left join node n on a.workflowidf=n.eoid
]]>
</select>
<select id="selectTransactedCount" parameterClass="lettersinfo" resultClass="java.util.HashMap">
<![CDATA[
select count(*)
from lettersinfo li left join letterbaseinfo lb on li.letterbaseinfeoid= lb.idf
left join approveinfo a on a.letterid =li.idf
left join node n on a.workflowidf=n.eoid
]]>
</select>
帮忙看一下这样写有木有错误。如果返回值写的是java.util.HashMap..那么值应该怎么提取
------解决方案--------------------Java code
<![CDATA[
]]>这种都可以去掉。。有也不会报错。。
还有
select lb.LETTERSOURCE ,li.LETTERNAMEF ,lb.LETTERTITLE ,n.nodename
from lettersinfo li left join letterbaseinfo lb on li.letterbaseinfeoid= lb.idf
left join approveinfo a on a.letterid =li.idf
left join node n on a.workflowidf=n.eoid
你都没有传递动态参数。。所以没有必要使用parameterClass="lettersinfo",
<resultMap class="lettersinfo" id="lettersinfoMap">
...... 省略。。
</resultMap>
这个完全没有必要。因为你没有用到。。
对于返回的map类型。java中可以直接通过map接收。。然后map.get("LETTERSOURCE[可用小写]")取值。。就行了。。
------解决方案--------------------
Object resultObject = getSqlMapClientTemplate().query(LETTER_SQL_MAP, lettersInfo);
if(resultObject == null || !(resultObject instanceof List)){
throw new DataAccessException("Query error:.....");
}
List resultList = (List)resultObject