Class ReviewDAO
java.lang.Object
com.JesacaLin.GrubGoblin_v13.daos.ReviewDAO
DAO class for managing Review entities in the database.
-
Constructor Summary
ConstructorsConstructorDescriptionReviewDAO
(DataSource dataSource) Constructs a new ReviewDAO with the given DataSource. -
Method Summary
Modifier and TypeMethodDescriptioncreateReview
(Review review, int dealId) Creates a new Review.int
deleteReviewById
(int reviewId) Deletes a Review by its ID.Retrieves all Reviews.getAllReviewsByDealId
(int dealId) Retrieves all Reviews for a specific deal.getReviewById
(int reviewId) Retrieves a Review by its ID.mapRowToReview
(org.springframework.jdbc.support.rowset.SqlRowSet rowSet) Maps a SqlRowSet to a Review.updateReview
(int id, Review review) Updates a Review.
-
Constructor Details
-
ReviewDAO
Constructs a new ReviewDAO with the given DataSource.- Parameters:
dataSource
- the DataSource to use for database access
-
-
Method Details
-
getReviewById
Retrieves a Review by its ID.- Parameters:
reviewId
- the ID of the Review to retrieve- Returns:
- the Review with the given ID, or null if no such Review exists
- Throws:
DaoException
- if a database access error occurs
-
getAllReviews
Retrieves all Reviews.- Returns:
- a list of all Reviews
- Throws:
DaoException
- if a database access error occurs
-
createReview
Creates a new Review.- Parameters:
review
- the Review to createdealId
- the ID of the deal associated with the review- Returns:
- the created Review
- Throws:
DaoException
- if a database access error occurs or if the Review data violates database constraints
-
updateReview
Updates a Review.- Parameters:
id
- the ID of the Review to updatereview
- the Review data to update- Returns:
- the updated Review
- Throws:
DaoException
- if a database access error occurs, if the Review data violates database constraints, or if no rows were affected by the update
-
deleteReviewById
public int deleteReviewById(int reviewId) Deletes a Review by its ID.- Parameters:
reviewId
- the ID of the Review to delete- Returns:
- the number of rows affected by the delete
- Throws:
DaoException
- if a database access error occurs or if the Review data violates database constraints
-
getAllReviewsByDealId
Retrieves all Reviews for a specific deal.- Parameters:
dealId
- the ID of the deal to retrieve Reviews for- Returns:
- a list of all Reviews for the specified deal
- Throws:
DaoException
- if a database access error occurs
-
mapRowToReview
Maps a SqlRowSet to a Review.- Parameters:
rowSet
- the SqlRowSet to map- Returns:
- the mapped Review
-