'There is a problem with how to use the DTO form in the mapper. Is there a mistake in my sql grammar?

I'm developing a web now. I'm trying to get what I type in my browser as ajax and store it in a database. When uploading multiple files simultaneously, converting the files into List format was successful. This file should be stored in the DTO object and stored in the database through sql grammar, but the value has not been obtained.

public class InputFile {
    public int id;
    public int usedShoesId;
    public List<String> imagePath;
    public Date createdAt;
    }

This is my DTO object.

        InputFile inputfile;
        inputfile = new InputFile();
        inputfile.setUsedShoesId(usedShoes.getId());
        inputfile.setImagePath(fileListForInsert);
        
        shoesDAO.insertFileListForInsert(inputfile);

And this is a bussiness object file.

public int insertFileListForInsert(InputFile inputfile);

In this way, it was received in the form of an object and handed over to the mapper.

    <insert id ="insertFileListForInsert" parameterType="com.shused.project.shoes.model.InputFile">
        <foreach collection="imagePath" item="item" separator=",">
            INSERT INTO `usedshoesimages`
            (
                `usedShoesId`
                ,`imagePath`
                ,`createdAt`
            )
            VALUES
            (
                #{usedShoesId}
                ,#{imagePath.value}
                ,now()
            )
            </foreach>
    </insert>

The form List is contained in an object called inputfile, so I tried to stack it in the database through repetitive statements.

[2m2022-03-29 01:17:11.824[0;39m [31mERROR[0;39m [35m18876[0;39m [2m---[0;39m [2m[nio-8080-exec-7][0;39m [36mo.a.c.c.C.[.[.[/].[dispatcherServlet]   [0;39m [2m:[0;39m Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: java.lang.UnsupportedOperationException
### The error may exist in file [C:MyProject\bin\main\mappers\ShoesMapper.xml]
### The error may involve com.shused.project.shoes.dao.ShoesDAO.insertFileListForInsert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO `usedshoesimages`    (     `usedShoesId`     ,`imagePath`     ,`createdAt`    )    VALUES    (     ?     ,?     ,now()    )     ,     INSERT INTO `usedshoesimages`    (     `usedShoesId`     ,`imagePath`     ,`createdAt`    )    VALUES    (     ?     ,?     ,now()    )
### Cause: java.lang.UnsupportedOperationException] with root cause

Is there an error in my sql grammar when an error occurs like this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source