插入数据:返回记录的id遇到的问题

service层的写法

插入数据:返回记录的id遇到的问题

dao层写法:

插入数据:返回记录的id遇到的问题

xml中的写法:

插入数据:返回记录的id遇到的问题

但是返回包错:

2018-01-13 11:16:46,303 ERROR [500.jsp] - Mapper method 'com.thinkgem.jeesite.modules.course.dao.CourseTermTimeDao.insertAndGetId' has an unsupported return type: class java.lang.String
org.apache.ibatis.binding.BindingException: Mapper method 'com.thinkgem.jeesite.modules.course.dao.CourseTermTimeDao.insertAndGetId' has an unsupported return type: class java.lang.String
    at org.apache.ibatis.binding.MapperMethod.rowCountResult(MapperMethod.java:91)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:51)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)


我用的是jeesite,数据可以插入,我的返回类型也是对着的,但真不知道为啥报类型错误?

答:

这样写是返回类型的错误。mapper文件中的update,delete,insert语句是不需要设置返回类型的,它们都是默认返回一个int,所以要在insert中返回类型为int,我获得id的方式是:

插入数据:返回记录的id遇到的问题