av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

MyBatis映射文件resultMap元素中使用多個(gè)association的方法

瀏覽:5日期:2023-10-19 16:35:00

現(xiàn)在有一張訂單表t_stockorder,其擁有id、code、client_id、merchandise_id、merchandise_number、order_date、operator_id這些字段,其中client_id關(guān)聯(lián)t_client表中code字段,merchandise_id關(guān)聯(lián)t_merchandise表的code字段,operator_id關(guān)聯(lián)t_employee表的code字段。

現(xiàn)在要通過(guò)SQL語(yǔ)句將訂單表中t_stockorder的數(shù)據(jù)全部查詢出來(lái),SQL語(yǔ)句如下所示:

select so.id, so.code, c.name cname, m.name mname, so.merchandise_number, so.order_date, e.name ename from inventory.t_stockorder so inner join inventory.t_client c on c.code = so.client_id inner join inventory.t_merchandise m on m.code = so.merchandise_id inner join inventory.t_employee e on e.code = so.operator_id

現(xiàn)在要在mapper映射文件中添加動(dòng)態(tài)Sql語(yǔ)句,一般情況下映射文件中的resultMap元素中只可以有一個(gè)association,那如何添加多個(gè)association到resultMap中呢?正確代碼如下圖所示:

<resultMap type='com.lwz.entity.Stockorder'> <id property='id' column='id' /> <result property='code' column='code' /> <result property='merchandiseNumber' column='merchandise_number' /> <result property='orderDate' column='order_date' /> <association property='client' javaType='Client' resultMap='ClientResultMap'></association> <association property='merchandise' javaType='Merchandise' resultMap='MerchandiseResultMap'></association> <association property='employee' javaType='Employee' resultMap='EmployeeResultMap'></association> </resultMap> <resultMap type='com.lwz.entity.Client'> <id property='code' column='code' /> <result property='name' column='cname' /> </resultMap> <resultMap type='com.lwz.entity.Merchandise'> <id property='code' column='code' /> <result property='name' column='mname' /> </resultMap> <resultMap type='com.lwz.entity.Employee'> <id property='code' column='code' /> <result property='name' column='ename' /> </resultMap> <!--通過(guò)實(shí)體作為篩選條件查詢--> <select resultMap='StockorderMap'> select so.id, so.code, c.name cname, m.name mname, so.merchandise_number, so.order_date, e.name ename from inventory.t_stockorder so inner join inventory.t_client c on c.code = so.client_id inner join inventory.t_merchandise m on m.code = so.merchandise_id inner join inventory.t_employee e on e.code = so.operator_id <where> <if test='id != null'>and id = #{id} </if> <if test='code != null and code != ’’'>and so.code = #[code] </if> <if test='client != null'>and client_id = #{client.code} </if> <if test='merchandise != null'>and merchandise_id = #{merchandise.code} </if> <if test='merchandiseNumber != null'>and merchandise_number = #{merchandiseNumber} </if> <if test='orderDate != null'>and order_date = #{orderDate} </if> <if test='employee != null'>and operator_id = #{employee.code} </if> </where> </select>

resultMap中association的各個(gè)屬性的含義:

property:映射實(shí)體類的字段或?qū)傩浴? colum:數(shù)據(jù)庫(kù)的列名或者列標(biāo)簽別名。 javaTyp:完整java類名或別名。 jdbcType支持的JDBC類型列表列出的JDBC類型。這個(gè)屬性只在insert,update或delete的時(shí)候針對(duì)允許空的列有用。 resultMap: 一個(gè)可以映射聯(lián)合嵌套結(jié)果集到一個(gè)適合的對(duì)象視圖上的ResultMap。這是一個(gè)替代的方式去調(diào)用另一個(gè)select語(yǔ)句。

到此這篇關(guān)于MyBatis映射文件resultMap元素中使用多個(gè)association的方法的文章就介紹到這了,更多相關(guān)MyBatis 多個(gè)association內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

相關(guān)文章:
主站蜘蛛池模板: 国产美女在线播放 | 自由成熟xxxx色视频 | 亚洲成人av| 97国产视频 | 国产又黄又粗 | 视频一区二区三区在线观看 | 国产伦精品一区二区三区照片 | 国产视频一区在线观看 | 五月婷婷中文字幕 | 日本黄色免费网站 | 欧美黑人性猛交 | 日韩高清精品免费观看 | 亚洲国产成人在线 | 精品成人av | 国产成人在线免费视频 | 国产福利视频在线 | 成人深夜| 欧美午夜精品 | 99超碰在线观看 | 欧美三根一起进三p | 日本免费在线观看视频 | 一级片aa | 日本在线不卡视频 | 黄视频免费在线观看 | 欧美激情国产精品 | 999在线视频 | 国产一区二区三区视频在线 | 欧美日韩精品久久久免费观看 | 免费av在线网站 | 人人爽人人干 | 少妇综合 | 黄色免费观看网站 | 久久免费看片 | 四虎成人精品 | a毛片大片 | 涩涩的动漫 | 免费美女网站 | 日本黄色免费看 | 欧美性猛交99久久久久99按摩 | 天堂一区二区三区 | 成人在线小视频 |