Mybatis配置相關

2021-08-14 18:04:41 字數 1226 閱讀 5564

新增mybatis-config.xml檔案,並且配置在sqlsessionfactorybean下

mybatis-config.xml 配置檔案

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

where if 語句

select 

id,title,

author,

created_time,

updated_time,

user,

channel,

system,

status,

category,

seqfrom

book

and title like concat(concat("%",#),"%")

and author like concat(concat("%",#),"%")

and category = #

order by $ $

limit #,#

mybatis自帶別名,左側是別名,右側為對應的parametertype型別,基本型別及包裝類注意區分

_byte byte

_long long

_short short

_int int

_integer int

_double double

_float float

_boolean boolean

string string

byte byte

long long

short short

int integer

integer integer

double double

float float

boolean boolean

date date

decimal bigdecimal

bigdecimal bigdecimal

自定義別名,在mybatis-config檔案中定義

# 會自動轉成字串,加上雙引號,類似於preparedstatement

$不轉義,傳原始值,在用 order by 語句時候需要用 $ $  statement ,見上例

Mybatis的相關配置及理解

parametertype 輸入引數型別 方法括號裡的引數型別 resulttype 查詢返回結果值的型別,返回型別 方法名後接 輸入引數 parametertype 1.簡單型別 基本八大型別 string型別 a.識別符號必須是value b.自動給string型別 原樣輸出 適用於 動態排序 ...

mybatis 相關總結

1.mybatis的等標籤詳解 2.mybatis處理集合 迴圈 陣列和in等語句的使用 3.int updatepaypassword long id,string paypassword 這種形式呼叫mybatis,無法通過引數名呼叫xml中的方法。只能通過 這種形式 如果想直接使用引數名稱在x...

Mybatis 三 Mybatis快取配置

強烈推薦乙個大神的人工智慧的教程 使用快取可以提高獲取資料的速度,避免頻繁的資料庫互動,尤其是在查詢越多,快取命中率越高的情況下,使用快取的作用就更加明顯了。一般提到mybatis快取的時候都是指二級快取,一級快取缺省會啟用。catch ioexception ignore public sqlse...