Class JDBCCommentRequester


  • @Technical
    @Bean
    public class JDBCCommentRequester
    extends Object
    A specific JDBC requester dedicated on the comments persisted in the underlying data source.
    • Constructor Detail

      • JDBCCommentRequester

        protected JDBCCommentRequester()
    • Method Detail

      • saveComment

        public Comment saveComment​(Connection con,
                                   Comment cmt)
                            throws SQLException
        Saves the specified comment with the specified connection onto a data source. Once saved, the comment passed as argument isn't updated with the persistence information and hence the returned comment instance should be used for further handling.
        Parameters:
        con - the connection to a data source.
        cmt - the comment to save.
        Returns:
        the comment that is saved into the data source with its unique identifier.
        Throws:
        SQLException - if an error occurs while saving the comment.
      • deleteComment

        public void deleteComment​(Connection con,
                                  CommentId id)
                           throws SQLException
        Deletes the comment identified by the specified primary key from the data source onto which the given connection is opened.
        Parameters:
        con - the connection to the data source.
        id - the unique identifier of the comment in the data source.
        Throws:
        SQLException - if an error occurs while removing the comment from the data source.
      • updateComment

        public void updateComment​(Connection con,
                                  Comment cmt)
                           throws SQLException
        Updates the comment representation in the data source by the specified one.
        Parameters:
        con - the connection to the data source.
        cmt - the updated comment.
        Throws:
        SQLException - if an error occurs while updating the comment in the data source.
      • moveComments

        public void moveComments​(Connection con,
                                 String fromResourceType,
                                 ResourceReference fromResource,
                                 String toResourceType,
                                 ResourceReference toResource)
                          throws SQLException
        Moves all the comments from the resource they commented to another resource as they comment this new resource instead of the previous one.
        Parameters:
        con - the connection to the data source.
        fromResourceType - the source type of the commented resource
        fromResource - the source unique identifier of the comment in the data source.
        toResourceType - the destination type of the commented resource
        toResource - the destination unique identifier of another comment in the data source.
        Throws:
        SQLException - if an error occurs during the operation.
      • getComment

        public Comment getComment​(Connection con,
                                  CommentId commentId)
                           throws SQLException
        Gets the comment identified by the specified identifier.
        Parameters:
        con - the connection to use for getting the comment.
        commentId - the identifier of the comment in the data source.
        Returns:
        the comment or null if no such comment is found.
        Throws:
        SQLException - if an error occurs during the comment fetching.