카테고리 없음

executeAndReturnKey / params

stdbc 2019. 12. 28. 02:27

public int thubmsUpComment(int commentId, int memberNo) {

  Map<String, Integer> params = new HashMap<>();
    params.put("commentId", commentId);
    params.put("memberNo", memberNo);
    System.out.println(params);
  return insertAction.executeAndReturnKey(params).intValue();
}

 

오류 : comment_id 는 null이 될 수 없다 = commentId를 파라미터로 찾지 못한다

 

 

수정: 객체로 넣어준다

public int thubmsUpComment(int commentId, int memberNo) {
  CommentUp commentUp = new CommentUp(commentId, memberNo);
  SqlParameterSource params = new BeanPropertySqlParameterSource(commentUp);
  return insertAction.executeAndReturnKey(params).intValue();
}

 

왜 파라미터를 못받는가

아직 모름