Exemplo n.º 1
0
    @Override
    public Comment mapRow(ResultSet rs, int rowNum) throws SQLException {
      Comment comment = new Comment();
      comment.setCommentId(rs.getInt("comment_Id"));
      comment.setPostId(rs.getInt("post_Id"));
      comment.setUserName(rs.getString("username"));
      comment.setEmail(rs.getString("email"));
      comment.setCommentText(rs.getString("comment_content"));
      comment.setCommentDate(rs.getDate("comment_date"));
      comment.setCommentPublish(rs.getBoolean("comment_publish"));

      return comment;
    }
Exemplo n.º 2
0
 @Override
 public void editComment(Comment comment) {
   jdbcTemplate.update(
       SQL_UPDATE_COMMENT,
       comment.getPostId(),
       comment.getUserName(),
       comment.getEmail(),
       comment.getCommentText(),
       comment.getCommentDate(),
       comment.isCommentPublish(),
       comment.getCommentId());
 }
Exemplo n.º 3
0
 @Override
 public Comment addComment(Comment comment) {
   jdbcTemplate.update(
       SQL_INSERT_COMMENT,
       comment.getPostId(),
       comment.getUserName(),
       comment.getEmail(),
       comment.getCommentText(),
       comment.getCommentDate());
   comment.setCommentId(jdbcTemplate.queryForObject("select LAST_INSERT_ID()", Integer.class));
   return comment;
 }