數據庫中存在int型的字段,但是初始值爲null,mybatis取值之後就會報錯,
org.apache.ibatis.binding.BindingException: Mapper method 'getSort' <br> (xx.yy.cc.DxxDAO) attempted to return null from a method with a primitive return type (int).
解決:採用了取巧的方式,將實體類對應的該字段設置成String類型,mybatis取出來之後自動轉換成string,不會報錯,業務邏輯上得自己判斷取出來的值爲null的實際用處。