-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Completed task #14
base: main
Are you sure you want to change the base?
Completed task #14
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User your custom data processing exception instead of runtime
throw new RuntimeException("Can't create connection to DB ", e); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add new line
} | ||
return Optional.ofNullable(book); | ||
} catch (SQLException e) { | ||
throw new RuntimeException(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include exception message
|
||
@Override | ||
public Book update(Book book) { | ||
String updateBookQuery = "UPDATE books SET title = ?, price = ?;"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we update deleted books?
} | ||
return book; | ||
} catch (SQLException e) { | ||
throw new RuntimeException(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include exception message and the book
connection.prepareStatement(deleteByIdQuery)) { | ||
deleteByIdStatement.setLong(1, id); | ||
int deletedRows = deleteByIdStatement.executeUpdate(); | ||
return deletedRows != 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return deletedRows != 0; | |
return deletedRows > 0; |
if (insertedRows < 1) { | ||
throw new RuntimeException("Expected to insert at least 1 row, but nothing was inserted"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
book should be included in the message
|
||
@Override | ||
public boolean deleteById(Long id) { | ||
String deleteByIdQuery = "UPDATE books SET is_deleted = true WHERE id = ?;"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String deleteByIdQuery = "UPDATE books SET is_deleted = true WHERE id = ?;"; | |
String deleteByIdQuery = "UPDATE books SET is_deleted = TRUE WHERE id = ?;"; | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
No description provided.