SpringBoot使用 整合通用mapper

2021-10-13 02:59:58 字數 2452 閱讀 5047

1.引入依賴

>

>

tk.mybatisgroupid

>

>

>

>

2.0.2version

>

dependency

>

2.寫bean類

//表名和類名一致可以省略

@table

(name =

"tb_user"

)public

class

user

implements

serializable

3.dao層

import com.hsp.bean.user;

public

inte***ce

extends

4.測試

@runwith

(springrunner.

class

)@springboottest

public

class

}}

select 方法: listselect(t record); 說明:根據實體中的屬性值進行查詢,查詢條件使用等號

方法: t selectbyprimarykey(object key); 說明:根據主鍵字段進行查詢,方法引數必須包含完整的主鍵屬性,

查詢條件使用等號

方法: listselectall(); 說明:查詢全部結果,select(null)方法能達到同樣的效果

方法: t selectone(t record); 說明:根據實體中的屬性進行查詢,只能有乙個返回值,有多個結果是丟擲異

常,查詢條件使用等號

方法: int selectcount(t record); 說明:根據實體中的屬性查詢總數,查詢條件使用等號

insert 方法: int insert(t record); 說明:儲存乙個實體,null的屬性也會儲存,不會使用資料庫預設值

方法: int insertselective(t record); 說明:儲存乙個實體,null的屬性不會儲存,會使用資料庫預設值

update 方法: int updatebyprimarykey(t record); 說明:根據主鍵更新實體全部字段,null值會被更新

方法: int updatebyprimarykeyselective(t record); 說明:根據主鍵更新屬性不為null的值

delete 方法: int delete(t record); 說明:根據實體屬性作為條件進行刪除,查詢條件使用等號

方法: int deletebyprimarykey(object key); 說明:根據主鍵字段進行刪除,方法引數必須包含完整的主鍵屬性

example方法 方法: listselectbyexample(object example); 說明:根據example條件進行查詢 重點:這

個查詢支援通過 example 類指定查詢列,通過 selectproperties 方法指定查詢列

方法: int selectcountbyexample(object example); 說明:根據example條件進行查詢總數

方法: int updatebyexample(@param("record") t record, @param("example") object example); 說明:根據

example條件更新實體 record 包含的全部屬性,null值會被更新

方法: int updatebyexampleselective(@param("record") t record, @param("example") object example); 說

明:根據example條件更新實體 record 包含的不是null的屬性值

方法: int deletebyexample(object example); 說明:根據example條件刪除資料

5.擴充套件複雜語句查詢

<?xml version="1.0" encoding="utf-8"?>

namespace

=>

"findbyuser"

resulttype

="user"

>

select

*from

tb_user

>

test

="name != null"

>

name like '%$%'

if>

test

="note != null"

>

and note like '%$%'

if>

where

>

select

>

>

SpringBoot整合Redis 使用操作工具類

org.springframework.boot spring boot starter data redis spring redis redisproperties redis資料庫索引 預設為0 redis database 0 timeout 1000 redis伺服器位址 host 127...

springboot整合JPA的快速使用

這是專案結構 先導入依賴 org.springframework.boot spring boot starter data jpa 其次配置yml檔案 spring datasource driver class name com.mysql.jdbc.driver url jdbc mysql ...

springBoot整合dubbo整合專案

傳統spring 整合dubbo,需要繁瑣的編寫一堆堆的 xml 配置檔案 而springboot整合dubbo後,不在需要寫 xml,通過jar包引用,完 成整合,通過註解的形式完成配置。提高我們的開發效率 目錄結構 1 服務層生產者開發 hs ldm server service 1.1新增du...