1. 程式人生 > >Mybatis採坑

Mybatis採坑

collection中的id需要取別名與之對應,否則出錯

<resultMap id="supplier" type="com.ch.cooker.tob.facade.pojo.dbo.SupplierOrgDbo">
    <id column="id" property="id"/>
    <result column="name" property="name"/>
    <result column="address" property="address"/>
    <result column="code" property="code"/>
    <result column="busi_name" property="busiName"/>
    <result column="handphone" property="handphone"/>
    <result column="org_a_id" property="salerId"/>

    <result column="licence" property="licence"/>
    <result column="permission" property="permission"/>
    <result column="status" property="status"/>

    <result column="date_start" property="contractDateStart"/>
    <result column="date_end" property="contractDateEnd"/>

    <collection property="goodsGroupVos" ofType="com.ch.cooker.tob.facade.pojo.dbo.GoodsGroupDbo" javaType="ArrayList">
        <id column="gid" property="id"/>
        <result column="group_name" property="groupName"/>
    </collection>
</resultMap>
<select id="getAllSupplier" resultMap="supplier">
    SELECT soe.id,soe.name,soe.address,soe.code,soe.busi_name,soe.handphone,soe.`enable`,
    soc.date_start,soc.date_end,soc.status,bs.licence,bs.permission,bgg.group_name,bgg.id gid
    FROM sys_org so
    LEFT JOIN sys_org_entity soe ON so.org_entity_id = soe.id
    LEFT JOIN sys_org_relation sor ON sor.org_b_id = so.id
    LEFT JOIN sys_org_contract soc ON soc.relation_id = sor.id
    LEFT JOIN busi_suppliers bs ON soe.id = bs.org_entity_id
    LEFT JOIN busi_goods_group bgg ON bgg.org_id = so.id
    <where> so.type=4
        <if test="supplier.orgId != null">
            AND so.id = #{supplier.orgId}
        </if>

        <if test="supplier.status != null">
            AND soe.enable = #{supplier.status}
        </if>
        <if test="supplier.name != null and supplier.name != ''">
            AND soe.name LIKE concat(concat('%',#{supplier.name}),'%')
        </if>
        <if test="supplier.salerId != null">
            AND sor.org_a_id = #{supplier.salerId}
        </if>
        <if test="current!=null">
            limit #{current},#{size}
        </if>
    </where>
</select>

相關推薦

mybatis記錄

動態sql對字串的判斷 之前只對null和空做過判斷,沒有對具體的內容做過判斷,這次開發過程中做了內容判斷結果死活不對 如下:status != '1' 始終無法判斷通過 後來查了資料需要改為status != '1'.toString() 突然想到了Java裡面的字串判斷

Mybatis

collection中的id需要取別名與之對應,否則出錯 <resultMap id="supplier" type="com.ch.cooker.tob.facade.pojo.dbo.S

spring boot整合mybatis之c3p0的詳細配置

text context ati reat source ast type fig oot 項目地址:https://gitee.com/zhangjunqing/spring-boot/tree/master/springboot-mybatis-notice 本人在c3

mybatis記錄

找不到 map myba body 技術 property .com img class 1. mapper xml resultMap 中定義 property 時不能出現空格 否則會出現反射錯誤,找不到 do 對應的 set 方法 mybatis 排坑記錄

springboot kafka整合(包括java程式碼不能傳送和消費kafka訊息的記錄)

kafka採坑記錄:     1、kafka服務端server.properties中的broker.id叢集內需要唯一。     2、kafka config檔案中listeners和advertised.listeners需要配置本機ip:9092

XLua與CSharp互動的點 : 熱修復有返回值的CSharp方法

1、假如CS的一個類中有如下邏輯:  1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 using XLua; 5 6 namespace LGSTEST

vue實錄

1.給link新增事件、給元件繫結原生事件 在vue-router1中使用v-link寫入路由,但是在vue-router2中要使用router-link寫入路由,在瀏覽器渲染的時候會把router-link渲染成a。 有時候需要為router-link註冊事件,對於一般的html元素,直接使用@clic

Mybatis專業戶

大多數開發者應該都使用過Hibernate或者Mybatis的框架,或多或少都踩過一些坑! 如在MyBatis/Ibatis中#和$的區別,#方式能夠很大程度防止sql注入,$方式無法防止Sql注入。所以,老司機 對新手說,最好用#。簡單的說#{}是經過預編譯的,是安全的,是未經過預編譯的,

leetcode add_binary

儘管add_binary在leetcode中是一個簡單難度,但是踩了不少坑,記錄一下 描述: 給兩個字串形式的二進位制數,要求求和並輸出字串形式的結果,其中a和b均不為空字串 樣例: a=“1010”,b="1011",輸出“10101”.   過程: 剛看到題目的時候覺得很簡單,只要

vue指南

入門時,一直不清楚 new Vue 和 Vue.component 選項的區別 new Vue 建立的是根例項 new Vue({ el : '#app', data(){} }) Vue.component 建立的是元件 Vue.component('but

Dubbo框架升級Log4j2

Apache Log4j 2是Log4j的升級版,它比Log4j 1.x 版本有了很大的效能提升,吸收了LogBack的先進功能,更通過優秀的鎖機制、LMAX Disruptor、"無垃圾"機制等先進特性,在效能上全面超越了Log4j和LogBack 升級Log4j2後的專

微信小程式記錄 ------- canvas 生成分享到朋友圈帶小程式碼的圖片

最近做了一個問卷類的小程式,其中的結果頁想讓使用者進行朋友圈分享轉發,網上搜索資料,得出解決思路,用 canvas 將頁面繪製生成圖片,然後儲存到手機相簿,最終效果如下: 在這裡我只寫頁面裡關於 canvas 生成圖片並進行儲存這個流程的相關程式碼,並且會

Vue專案打包到spring的之路

Vue專案打包到spring的採坑之路 一、打包前的配置 配置utils // Extract CSS when that option is specified // (which is the case during production build

oracle11g資料庫安裝記錄 Oracle the network adapter could not establish the connection

第一處坑: 解決方案: 原文:https://blog.csdn.net/yhj198927/article/details/49178279  1.開啟oracle的“Net Manager”   2.開啟“監聽程式”   3.開啟“資料庫服務”  

Spring-boot整合Mybatis:不能找到@MapperScan標籤

       開發工具:Ideal        使用場景:Demo 問題描述:        Spring

【備忘】關於tp動態註冊路由的挖坑經驗

教訓: 自我感覺沒問題的路由配置今天出了個嚴重忽略是路由造成的問題,以至於花了2個小時才解決,血的教訓,特此備忘! 正文: 我的系統最近加了個模組,舉例:叫代理模組;模組名為:agent。所有功能開發完之後,開始上線,但由於測試人員說:www.game.com/agent 訪問會報錯,查

facenet之旅,主要記錄一些用facenet過程中遇到的大大小小的問題

問題1:Unable to run align_dataset_mtcnn.py getting an attribute error module ‘facenet’ has no attribute ‘store_revision_info’ 使用anaconda的環境,將facen

sysbench花式之一:自增值導致的TPS不可靠

那是一個風和日麗的春天,本人在讀了幾篇sysbench的使用文件,外加找朋友要了個sysbench安裝包,裝上跑了一下後,感覺sysbench也就這麼回事,自己已經完全掌握了,可以遊刃有餘的應對公司交給我的測試專案了。沒錯,科學證明,真的不要亂立flag,這樣會很扎心的。總之,懷著自信滿滿的心情,我

datax體驗

因為公司需要使用greenplum,而官方的datax版本在導資料到greenplum時,速度是非常慢的(嚴格說是datax導資料到postgresql,在匯入到GP時,資料走的是master,一條一條insert的,當然是慢)。 所以,這裡採用了別人開發好的支援GP 的datax版本:https://gi

bootstrap-select

bootstrap-select採坑 1.class="selectpicker" 普通的下拉框功能 2.title="請選擇城市名稱" title的作用與palcehoder一樣。 3.select class="selectpicker" multiple selectpicker和multiple屬性的