Mybatis多參數(shù)及實(shí)體對(duì)象傳遞實(shí)例講解
在使用Mybatis的時(shí)候,經(jīng)常會(huì)有各種各樣的參數(shù)傳遞,不同類型,不同個(gè)數(shù)的參數(shù)。
先上個(gè)例子:
public List<LifetouchRelease> findOfficeList(@Param("lifetouchRelease") LifetouchRelease lifetouchRelease, @Param("advertisementId") String advertisementId, @Param("officeName") String officeName, @Param("isOnline") Integer isOnline); <select id="findOfficeList" resultType="LifetouchRelease"> SELECT <include refid="lifetouchReleaseColumns"/> FROM lifetouch_release a <include refid="lifetouchReleaseJoins"/> <where> <if test="lifetouchRelease.typeIdentification > 0"> AND a.type_identification = #{lifetouchRelease.typeIdentification} </if> <if test="lifetouchRelease.category != null andlifetouchRelease.category.id != null and lifetouchRelease.category.id != ''"> AND a.release_type_id = #{lifetouchRelease.category.id} </if> AND a.office_id is not null AND a.advertisement_id like '%${advertisementId}%' AND (select name from sys_office where id=a.office_id) like '%${officeName}%' <if test="isOnline != null"> AND a.del_flag = #{isOnline} </if> </where> <choose> <when test="lifetouchRelease.page !=null andlifetouchRelease.page.orderBy != null and lifetouchRelease.page.orderBy != ''"> ORDER BY ${lifetouchRelease.page.orderBy} </when> <otherwise> ORDER BY a.update_date DESC </otherwise> </choose> </select>
上面是一個(gè)包含:實(shí)體對(duì)象,普通類型,多個(gè)參數(shù)的傳遞。
多個(gè)參數(shù):使用注解的方式實(shí)現(xiàn)
實(shí)體對(duì)象:實(shí)體對(duì)象跟普通類型參數(shù)傳遞方法一樣,只是在用的時(shí)候,以 對(duì)象名.(點(diǎn))對(duì)象屬性名 的方式調(diào)用就可以了。
其它傳遞,不過數(shù)據(jù)類型多復(fù)雜也是如此。
以上所述是小編給大家介紹的Mybatis多參數(shù)及實(shí)體對(duì)象傳遞實(shí)例講解,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
Java9版本新特性同一個(gè)Jar支持多JDK版本運(yùn)行
這篇文章主要為大家介紹了Java9新版本的特性之同一個(gè)Jar支持多JDK版本運(yùn)行的示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步2022-03-03java創(chuàng)建txt文件并寫入內(nèi)容的方法代碼示例
這篇文章主要介紹了java創(chuàng)建txt文件并寫入內(nèi)容的兩種方法,分別是使用java.io.FileWriter和BufferedWriter,以及使用Java7的java.nio.file包中的Files和Path類,需要的朋友可以參考下2025-01-01基于JVM 調(diào)優(yōu)的技巧總結(jié)分析
本篇文章是對(duì)JVM 調(diào)優(yōu)的技巧進(jìn)行了總結(jié)和分析。需要的朋友參考下2013-05-05Java Feign微服務(wù)接口調(diào)用方法詳細(xì)講解
現(xiàn)如今微服務(wù)架構(gòu)十分流行,而采用微服務(wù)構(gòu)建系統(tǒng)也會(huì)帶來更清晰的業(yè)務(wù)劃分和可擴(kuò)展性。java如果使用微服務(wù)就離不開springcloud,我這里是把服務(wù)注冊(cè)到nacos上,各個(gè)服務(wù)之間的調(diào)用使用feign2023-01-01解決idea2020 maven無法自動(dòng)導(dǎo)包的問題
這篇文章主要介紹了解決idea2020 maven無法自動(dòng)導(dǎo)包的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2021-02-02