Exemple #1
0
  /**
   * Removes the Comment specified by the commentId.
   *
   * @param commentId id of Comment to remove
   * @return removed Comment or null if one was not found with the id
   */
  public Comment removeComment(final long commentId) {
    Comment removedComment = null;

    if (comments != null) {
      for (int index = comments.size() - 1; index >= 0; --index) {
        Comment currentComment = comments.get(index);

        if (currentComment.getId() == commentId) {
          removedComment = comments.remove(index);
          break;
        }
      }
    }

    return removedComment;
  }
 @Override
 public Comment persistComment(Comment comment) {
   check();
   this.em.persist(comment);
   if (this.pessimisticLocking) {
     return this.em.find(
         CommentImpl.class, comment.getId(), LockModeType.PESSIMISTIC_FORCE_INCREMENT);
   }
   return comment;
 }