ibatis一对多映射
中继VO如下属性:
public class RelayInfoVO {
? //中继信息
? private String bswitcherNames;//本端局
? private String dswitcherNames;//对端局
? private String signalStatCount;//信令数
? private String relayStatCount;//中继数
? private List signalVO;//信令List,用来存放信令List的
??
? ……
=====================================================================================
信令VO如下属性:
public class SignalInfoVO {
? //信令信息
? private String bswitchers;//本端局
? private String dswitchers;//对端局
? private String signalType;//信令类型
? private String signalCount;//信令个数
? ……
=====================================================================================
ibatis的XML如下配置:
注:为中继VO,column="{bswitcherNames=bswitcherName,dswitcherNames=DSWITCHERNAME}" 是为select="getSignalInfo"所传递的参数。select="getSignalInfo"为所要调用的SELECT查询语句。
? <resultMap id="RelayInfoVO-Result-list" column="BSWITCHERNAME" nullValue=""/>
? ? <result property="dswitcherNames" column="DSWITCHERNAME" nullValue=""/>
? ? <result property="signalStatCount" column="SIGNALSTATCOUNT" nullValue=""/>
? ? <result property="relayStatCount" column="RELAYSTATCOUNT" nullValue=""/>
? ? <result property="signalVO" column="{bswitcherNames=bswitcherName,dswitcherNames=DSWITCHERNAME}" select="getSignalInfo"/>
? </resultMap>
注:为信令VO
? <resultMap id="SignalInfoVO-Result-list" column="BSWITCHERS" nullValue=""/>
? ? <result property="dswitchers" column="DSWITCHERS" nullValue=""/>
? ? <result property="signalType" column="SIGNALTYPE" nullValue=""/>
? ? <result property="signalCount" column="SIGCOUTN" nullValue=""/>
? </resultMap>
? <select id="getRSInfo" resultMap="RelayInfoVO-Result-list">
? ??
? ? ? ……
? </select>
<select id="getSignalInfo" resultMap="SignalInfoVO-Result-list">
? ? ? ? select c.switcherName as BSWITCHERS,b.switcherName as DSWITCHERS,linkType as SIGNALTYPE,count(*) as SIGCOUTN
? ? ? ? where?
? ? ? ? ? c.switcherName=#bswitcherNames#
? ? ? ? and b.switcherName=#dswitcherNames#
? ? ? ? group by b.switcherName,b.ATTACHING,c.switcherName,linktype
? ? ? ? order by c.switcherName,b.SWITCHERORDER,linktype
? </select>