需求:我想把数据库中的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相同