Execute the query statement in Mybatis, and return the solution that the empty null field is not displayed

       When querying a table in the database for paging output, at first I thought it was a problem with the PageHelper paging component, but later I found that Mybatis output directly had no fields. For background data processing output, this is a fatal problem, so this problem is solved by modifying the configuration of Mybatis.

mybatis.configuration.call-setters-on-nulls=true

     In springboot it sometimes doesn't work. After research, in fact, it is enough to add the configuration of callSettersOnNulls in SqlSessionFactory. Here is a record:

SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
configuration.setCallSettersOnNulls(true);
bean.setConfiguration(configuration);

If you encounter the above problems, you can use this method to solve them!

Guess you like

Origin blog.csdn.net/Angel_asp/article/details/130250888