在SpringBoot中自定義sql語句

2021-08-14 01:34:43 字數 1266 閱讀 7358

關於在springboot中自定義sql語句

public

inte***ce

int countbyexample(messageexample example);

int deletebyexample(messageexample example);

int deletebyprimarykey(string id);

int insert(message record);

int insertselective(message record);

listselectbyexample(messageexample example);

message selectbyprimarykey(string id);

int updatebyexampleselective(@param("record") message record, @param("example") messageexample example);

int updatebyexample(@param("record") message record, @param("example") messageexample example);

int updatebyprimarykeyselective(message record);

int updatebyprimarykey(message record);

@select("select *,count(*) as count from message where toid = # group by formid order by created_date desc limit #, #")

listselectconversationlist(@param("userid") string userid, @param("offset") int offset, @param("limit") int limit);

@update("update message set has_read = 1 where conversation_id = #")

void updatemessagehasreadbyconversationid(@param("conversationid") string conversationid);}}

上面**中selectconversationlist()就是自定義的sql,只需要在方法的上面加上註解@select即可,當然還有其他的例如delete,update。引數怎樣定義在上面也有寫到

自定義註解在springboot自動裝配中的應用

springboot自動裝配核心原理 通過 condition註解,判斷是否要將當前bean註冊到spring容器。condition用法 放在 bean下面,動態判斷是否需要註冊bean,condition的判斷邏輯寫在其後括號中,示例 如下 public inte ce userdao publ...

springboot中自定義退出碼

public static void main string args override public int getexitcode 這裡只需要實現exitcodegenerator就可以了,重寫getexitcode 方法,返回自定義碼。而且我們可以監聽退出的事件 bean sampleeven...

自定義Spring Boot裝配

spring boot自動配置會嘗試根據新增的jar依賴項自動配置spring應用程式。使用 componentscan 查詢您的bean 和使用 autowired 進行建構函式注入 自動配置類使用 conditionalonclass和 conditionalo singbean注釋,condi...