当传入的参数为对象时,需要使用这个注解,否则可能会出现如下异常:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'essay' in 'class com.example.easyGo.entity.Essay'
尤其是update语句时。
另外,mybatis会默认把所有字段附上默认值,多数时候为null。这时候会发现,mysql的默认值设置不生效了。
解决方案是:在实体类中就设置默认值,比如:private int score = 100;