1

I am trying update password for database using mybatis:

update person 
   set name = #{name}, 
       address = #{address}, 
       phoneNumber = #{phoneNumber},
       balance = #{balance}, 
       password = #{password}, 
       id = #{new_id} 
 where id = #{id}

However, got following exception:

org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'id' cannot be null
### The error may involve com.lsp.mybatis.PersonMapper.update-Inline
### The error occurred while setting parameters
### SQL: update person set name = ?, address = ?, phoneNumber = ?             ,balance = ?, password = ?, id = ? where id = ?
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'id' cannot be null

I have specified the user id I want to update. Why is it saying "id cannot be null"?

Can someone tell me what I did do wrong?

1
  • Do you want to update ID or password? Commented Nov 22, 2013 at 21:46

1 Answer 1

2

Remove in the query: id = #{new_id}.

So, the query will be:

update person 
   set name = #{name}, 
       address = #{address}, 
       phoneNumber = #{phoneNumber},
       balance = #{balance}, 
       password = #{password}
 where id = #{id}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.