请问各位java高手,java(spring)如何解析oracle返回的list和map对象?
例如oracle的函数返回记录集:FUNCTIONFUNC_Wechat_queryClmList(i_NotifyPhoneNoinvarchar2,i_Typeinv...
例如oracle的函数返回记录集:
FUNCTION FUNC_Wechat_queryClmList(i_NotifyPhoneNo in varchar2, i_Type in varchar2)
RETURN queryClmListList IS
resultlist queryClmListList;
BEGIN
--获取理赔赔案信息
SELECT a.insurantname,
a.licenseno,
a.CardNo,
a.policyno,
a.applytelephone,
a.claimno,
a.caseno,
a.notifyman,
a.NotifyPhoneNo,
a.notifydate,
a.damagedate,
a.damageplace,
a.unitname,
a.unitcode BULK COLLECT
INTO resultlist
FROM (SELECT c.insurantname,
c.licenseno,
p.sid CardNo,
c.policyno,
p.applytelephone,
c.claimno,
c.caseno,
c.notifyman,
c.telephone NotifyPhoneNo,
c.notifydate,
c.damagedate,
(select a.areaname from d_area a where a.areacode = c.province) ||
(select a.areaname from d_area a where a.areacode = c.city) ||
(select a.areaname from d_area a where a.areacode = c.area) ||
c.damageplace as damageplace,
(select du.UnitName from d_unit du where du.unitcode = c.unitcode) as UnitName,
c.unitcode
FROM c_claim c, p_public_policy p
WHERE c.applyno = p.applyno
AND c.applyendorseno = p.applyendorseno
AND (c.Telephone = trim(i_NotifyPhoneNo) OR c.Telephone = '0' || trim(i_NotifyPhoneNo))
AND c.ismain = '1'
AND ((i_Type = '1' and c.endstatus = '0') OR i_Type = '2')
ORDER BY c.notifydate desc) a
WHERE rownum < 10;
return resultlist;
end FUNC_Wechat_queryClmList;
那么在java端,spring的jdbc端如何解析resultlist对象,并将它封装为list呢? 展开
FUNCTION FUNC_Wechat_queryClmList(i_NotifyPhoneNo in varchar2, i_Type in varchar2)
RETURN queryClmListList IS
resultlist queryClmListList;
BEGIN
--获取理赔赔案信息
SELECT a.insurantname,
a.licenseno,
a.CardNo,
a.policyno,
a.applytelephone,
a.claimno,
a.caseno,
a.notifyman,
a.NotifyPhoneNo,
a.notifydate,
a.damagedate,
a.damageplace,
a.unitname,
a.unitcode BULK COLLECT
INTO resultlist
FROM (SELECT c.insurantname,
c.licenseno,
p.sid CardNo,
c.policyno,
p.applytelephone,
c.claimno,
c.caseno,
c.notifyman,
c.telephone NotifyPhoneNo,
c.notifydate,
c.damagedate,
(select a.areaname from d_area a where a.areacode = c.province) ||
(select a.areaname from d_area a where a.areacode = c.city) ||
(select a.areaname from d_area a where a.areacode = c.area) ||
c.damageplace as damageplace,
(select du.UnitName from d_unit du where du.unitcode = c.unitcode) as UnitName,
c.unitcode
FROM c_claim c, p_public_policy p
WHERE c.applyno = p.applyno
AND c.applyendorseno = p.applyendorseno
AND (c.Telephone = trim(i_NotifyPhoneNo) OR c.Telephone = '0' || trim(i_NotifyPhoneNo))
AND c.ismain = '1'
AND ((i_Type = '1' and c.endstatus = '0') OR i_Type = '2')
ORDER BY c.notifydate desc) a
WHERE rownum < 10;
return resultlist;
end FUNC_Wechat_queryClmList;
那么在java端,spring的jdbc端如何解析resultlist对象,并将它封装为list呢? 展开
2个回答
展开全部
public List<HlVO> getHlVoByZyid(String zyid) {
String sql = "select a.id,b.zyxsz,a.hbdw,a.hbzsl,a.hlrq,a.xgrq from mdt_hlb a, mdt_sjzd_dmb b where a.zyid=b.id and a.zyid = ? order by a.hlrq";
List<HlVO> hlVoList = getJdbcTemplate().query(sql, new Object[]{zyid}, new RowMapper(){
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
HlVO hlVo = new HlVO();
hlVo.setId(rs.getString(1));
hlVo.setZyxsz(rs.getString(2));
hlVo.setHbdw(rs.getInt(3));
hlVo.setHbzsl(rs.getDouble(4));
hlVo.setHlrq(rs.getDate(5));
hlVo.setXgrq(rs.getDate(6));
return hlVo;
}
});
return hlVoList;
}
这个是例子,你可以看到,从数据库获取来的数据,没条记录的每个列都可以获得,那么根据你的需求获取
建立一个类,把获取到的塞给这个类的对象就好了。
String sql = "select a.id,b.zyxsz,a.hbdw,a.hbzsl,a.hlrq,a.xgrq from mdt_hlb a, mdt_sjzd_dmb b where a.zyid=b.id and a.zyid = ? order by a.hlrq";
List<HlVO> hlVoList = getJdbcTemplate().query(sql, new Object[]{zyid}, new RowMapper(){
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
HlVO hlVo = new HlVO();
hlVo.setId(rs.getString(1));
hlVo.setZyxsz(rs.getString(2));
hlVo.setHbdw(rs.getInt(3));
hlVo.setHbzsl(rs.getDouble(4));
hlVo.setHlrq(rs.getDate(5));
hlVo.setXgrq(rs.getDate(6));
return hlVo;
}
});
return hlVoList;
}
这个是例子,你可以看到,从数据库获取来的数据,没条记录的每个列都可以获得,那么根据你的需求获取
建立一个类,把获取到的塞给这个类的对象就好了。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询