use of com.tvd12.ezydata.example.jpa.exception.BookNotFoundException in project ezyfox-examples by tvd12.
the class BookService method getBook.
public BookData getBook(Long bookId) {
Book book = bookRepository.findById(bookId);
if (book == null) {
throw new BookNotFoundException("not found book with id: " + bookId);
}
final Author author = authorRepository.findById(book.getAuthorId());
final Category category = categoryRepository.findById(book.getCategoryId());
return entityToDataConverter.toData(book, author, category);
}
Aggregations