title: POJO as parameter for insert in Mybatis
body: <p>I have this Domain Object called UserDTO </p>
  
  <p>here is my mapper.xml file config</p>
  
  <pre><code>&lt;insert id="insertUser" useGeneratedKeys="true" keyProperty="id" parameterType="com.myapp.dto.UserDTO"&gt;
      insert into
      tblusers(username,password,email,phone,role,is_active,security_question,securtiy_answer,first_name,last_name)
      values(#{username},#{password},#{email},#{phone},#{role,typeHandler=com.greenflight.typehandlers.StringArrayListTypeHandler},#{is_active},#{security_question},#{securtiy_answer},#{first_name},#{last_name})
  &lt;/insert&gt;
  </code></pre>
  
  <p>But this is throwing Exception like this </p>
  
  <pre><code>  Caused by: org.apache.ibatis.exceptions.PersistenceException: 
  ### Error updating database.  Cause: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column #1 from result set.  Cause: org.postgresql.util.PSQLException: Bad value for type long : asdfds
  ### The error may involve org.mybatis.myapp.Mapper.insertUser-Inline
  ### The error occurred while setting parameters
  ### SQL: insert into   tblusers(username,password,email,phone,role,is_active,security_question,securtiy_answer,first_name,last_name)   values(?,?,?,?,?,?,?,?,?,?)
  ### Cause: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column #1 from result set.  Cause: org.postgresql.util.PSQLException: Bad value for type long : asdfds
      at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
      at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200)
      at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:185)
      at com.greenflight.dao.UserDAO.CreateNewUser(UserDAO.java:98)
  </code></pre>
  
  <p>I have gone through the documents of mybatis and was not able to find good example on how to send Domain objects as parameters .</p>
  
  <p>can anybody show me the solution</p>