1. 程式人生 > >mybatis將資料庫中tinyint型別自動轉換為pojo的boolean型別

mybatis將資料庫中tinyint型別自動轉換為pojo的boolean型別

需求:我想把資料庫中的tinyint(1)裡面儲存的1/0,自動轉換為實體類的boolean型別,方便輸出到前臺Combobox預設選中項。

解決方案:

    A.將資料庫中的tinyint(1)更改為tinyint(2)

    B.在jdbcUrl中加入&tinyInt1isBit=false

    C.

@Select("SELECT id AS valueField, value AS textField, defaultChecked AS selected FROM sys_dictionary WHERE type= #{type} ORDER BY seq DESC")
@ResultType(Combobox.class)
List<Combobox> createComboboxByType(@Param("type") String type);

   sql語句中的欄位必須Combobox相同