Updating SQL db with List – Java and MyBatis

Is it possible to insert a list in MyBatis?

This is the Java code:

    public void createSubjectPrivileges(final List<SubjectPrivilegesFormDTO> subjectPrivilegesFormDTOList) {

What would be the MyBatis code, in case this is possible?

<insert id="createSubjectPrivileges" parameterType="?">
        insert into x (
        ) values (
        #{d, jdbcType=NUMERIC},
        #{e, jdbcType=NUMERIC},
        #{f, jdbcType=NUMERIC}

I can always iterate throught the list in Java and insert one each time, but that’s not very good in performance terms, from my point of view.

Thanks in advance.

Source: oop

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.