Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

BakhmetIvan
Copy link

No description provided.

Copy link

@okuzan okuzan left a 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);
}
}
}
Copy link

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);
Copy link

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 = ?;";
Copy link

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);
Copy link

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;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return deletedRows != 0;
return deletedRows > 0;

Comment on lines 29 to 31
if (insertedRows < 1) {
throw new RuntimeException("Expected to insert at least 1 row, but nothing was inserted");
}
Copy link

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 = ?;";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
String deleteByIdQuery = "UPDATE books SET is_deleted = true WHERE id = ?;";
String deleteByIdQuery = "UPDATE books SET is_deleted = TRUE WHERE id = ?;";

@BakhmetIvan BakhmetIvan requested a review from okuzan August 3, 2023 15:15
Copy link

@kozhukhovsky kozhukhovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants