MySQL保存boolean值時用1代表TRUE
,0代表FALSE
。
boolean在mysql裏的類型爲tinyint(1)。MySQL裏有四個常量:true,false,TRUE,FALSE分別代表1,0,1,0。
create table test
(
id int primary key,
bl boolean
)
這樣是可以創建成功。查看建表後的語句會發現,mysql把它替換成tinyint(1)。
在pojo裏直接定義該屬性爲布爾值即可:private Boolean statusv