1.參數注入
1.1用#{0},#{1}的形式,0代表第一個參數,1代表第二個參數
public List
『 SELECT ID id, WORKER_ID workerId, UPDATE_DATE updateDate SELECT COUNT(1)
SELECT COUNT(1)
SELECT COUNT(1)
SELECT COUNT(1) public Integer queryCountByWorkerId(@param(“workerId”)String workerId);
SELECT COUNT(1)Name
『 SELECT COUNT(1)🀎A 『 〟螅* Id}
2.2直接回傳物件
sql public class ParamVo {
private String sql;
//getter setter 省略
/**
* @param vo
* @return */
public List
> excuteSelectSql(ParamVo vo);
3.3xml:
${sql🀦
${sql}
這裡不知道返回類型用map或者hashmap作為返回
4.include:有時候兩個方法要返回的字段都一樣或者where子句一樣,這樣為了避免重複寫程式碼,就抽出來用include
4.1定義子句相同部分
FROM tableName1 F
RIGHT JOIN tableName2 C ON F.WORKER_ID = C.WORKER_ID JOIN tableName2 C ON F.WORKER_ID = C.WORKER_ID 53. _ID = #{workerId}
ORDER BY C.CREATE_DATE DESC