title: MyBatis Insert List values
body: <p>Mapper.xml (Mapper xml file)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-mapper.dtd"&gt;
  &lt;mapper namespace="TestDAO"&gt;
  &lt;insert id="insertEmployeeList" parameterType="java.util.List"&gt;
  INSERT INTO EMPLOYEE (id, name) VALUES
  &lt;foreach collection="list" item="element" index="index" open="(" separator=","  close=")"&gt;
  #{element.id}, #{element.name}
  &lt;/foreach&gt;
  &lt;/insert&gt;
  &lt;/mapper&gt;
  </code></pre>
  
  <p>Employee.java</p>
  
  <pre><code>public class Employee {
    private List&lt;Emp&gt; list = new ArrayList&lt;Emp&gt;();
    public List&lt;Emp&gt; getList() {
      return list;
    }
    public void setList(List&lt;Emp&gt; list) {
      this.list = list;
    }
  }
  </code></pre>
  
  <p>Emp.java</p>
  
  <pre><code>public class Emp {
    public Emp(int id, String name) {
      this.id = id;
      this.name = name;
    }
    private int id;
    private String name;
    public int getId() {
      return id;
    }
    public void setId(int id) {
      this.id = id;
    }
    public String getName() {
      return name;
    }
    public void setName(String name) {
      this.name = name;
    }
  }
  </code></pre>
  
  <p>TestDAO.java</p>
  
  <pre><code>public interface TestDAO {
  public Integer insertEmployeeList(List&lt;Emp&gt; empList) throws SQLException;
  }
  </code></pre>
  
  <p>Main.java</p>
  
  <pre><code>public class Main {
     public static void main (String args[]) {
         TestDAO tm = session.getMapper(TestDAO.class);
         Employee e = new Employee();
         Emp e11 = new Emp(123,"abc");
         Emp e12 = new Emp(456,"def");
         e.getList().add(e11);
         e.getList().add(e12);
         tm.insertEmployeeList(e.getList());
     }
  }
  </code></pre>
  
  <p>Exception I'm getting is:</p>
  
  <pre><code>Error updating database.  Cause: java.sql.SQLSyntaxErrorException: ORA-00913: too many values
  The error may involve com.XXXX.sample.test.dao.TestDAO.insertEmployeeList-Inline
  The error occurred while setting parameters
  Cause: java.sql.SQLSyntaxErrorException: ORA-00913: too many values
  </code></pre>