当前位置:网站首页>How to package the parsed Excel data into objects and write this object set into the database?

How to package the parsed Excel data into objects and write this object set into the database?

2022-07-07 04:46:00 CSDN Q & A

The phenomenon and background of the problem

Today, I am learning parsing Excel file , Write the parsed data into the database , But the parsed data is a set , I don't know how to write to the database , Always report mistakes

mapper Code

img

mybatis Of xml file

img

service layer

img

img

This is a controller layer , Will be resolved list The objects in the collection are written to the database

img

This is the analysis Excel Get the object

img

This is the content of the error report , I didn't know how to do it for hours , Write only list The first one in the collection , The latter cannot be written into the database
org.apache.ibatis.binding.BindingException: Mapper method 'com.xjh.exceljiexi.mapper.UserExcelModelMapper.insert' has an unsupported return type: class com.xjh.exceljiexi.domain.UserExcelModel
at org.apache.ibatis.binding.MapperMethod.rowCountResult(MapperMethod.java:118) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:145) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86) ~[mybatis-3.5.9.jar:3.5.9]
at com.sun.proxy.$Proxy59.insert(Unknown Source) ~[na:na]
at com.xjh.exceljiexi.service.impl.UserExcelModelImpl.addUser(UserExcelModelImpl.java:24) ~[classes/:na]
at com.xjh.exceljiexi.controller.FileController.readExcel(FileController.java:53) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_301]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_301]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_301]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_301]

This error has been stuck for threeorfour hours , How to modify the code to complete this function ? Ask for an answer




Take the answer :

Have a look at , I didn't find anything wrong , But I have a little suggestion , You can set breakpoints when inserting data into the database , Check the currently inserted domain Whether the object is wrong , If it's normal , That means all your previous codes are correct , Only myBatis There are some problems here . Then continue to look slowly


原网站

版权声明
本文为[CSDN Q & A]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202061651222637.html