Here are the examples of the java api com.bookstore.entity.Book taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
90 Examples
19
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void displayBook() {
Book book = bookRepository.findByreplacedle("Young Boy");
System.out.println(book);
}
19
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void findEbookByAuthorNameViaBookRepository() {
Book book = bookRepository.findByAuthorName("Alicia Tom");
System.out.println(book + " | " + (book instanceof Ebook));
}
19
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void findEbookByAuthorNameViaEbookRepository() {
Book ebook = ebookRepository.findByAuthorName("Alicia Tom");
System.out.println(ebook + " | " + (ebook instanceof Ebook));
}
19
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@Transactional(readOnly = true)
public void fetchAuthorByBookDto() {
Book book = bookRepository.findById(4L).orElseThrow();
AuthorDto author = authorRepository.queryByBooks(book);
System.out.println("Fetched author (DTO): " + author.getName());
}
19
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
// second query/request
public Author fetchAuthorOfBookGood(Book b) {
// Explicit JPQL
// return authorRepository.fetchByBooks(b);
// Query Builder
return authorRepository.findByBooks(b);
}
19
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void displayPublishersWithBooksAndAuthors() {
List<Publisher> publishers = publisherRepository.findAll();
for (Publisher publisher : publishers) {
System.out.println("\nPublisher: " + publisher);
List<Book> books = publisher.getBooks();
System.out.println("No of books: " + books.size() + ", " + books);
for (Book book : books) {
System.out.println("Book: " + book.getreplacedle() + " written by: " + book.getAuthor());
}
}
}
19
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void displayPublishersByIdBetween1And3WithBooksAndAuthors() {
List<Publisher> publishers = publisherRepository.fetchAllIdBetween1And3();
for (Publisher publisher : publishers) {
System.out.println("\nPublisher: " + publisher);
List<Book> books = publisher.getBooks();
System.out.println("No of books: " + books.size() + ", " + books);
for (Book book : books) {
System.out.println("Book: " + book.getreplacedle() + " written by: " + book.getAuthor());
}
}
}
19
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void displayPublishersByIdWithBooksAndAuthors() {
List<Publisher> publishers = publisherRepository.findByIdLessThanOrderByCompanyDesc(2L);
for (Publisher publisher : publishers) {
System.out.println("\nPublisher: " + publisher);
List<Book> books = publisher.getBooks();
System.out.println("No of books: " + books.size() + ", " + books);
for (Book book : books) {
System.out.println("Book: " + book.getreplacedle() + " written by: " + book.getAuthor());
}
}
}
19
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void displayPublishersWithBooksAndAuthorsWithSpec() {
List<Publisher> publishers = publisherRepository.findAll(isIdGt2());
for (Publisher publisher : publishers) {
System.out.println("\nPublisher: " + publisher);
List<Book> books = publisher.getBooks();
System.out.println("No of books: " + books.size() + ", " + books);
for (Book book : books) {
System.out.println("Book: " + book.getreplacedle() + " written by: " + book.getAuthor());
}
}
}
19
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
// cache enreplacedies in SLC
public void fetchBook() {
Book book = bookRepository.findById(1L).orElseThrow();
}
19
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void displayBookById() {
// LEFT JOIN
Book book = bookRepositoryFetchModeJoin.findById(1L).orElseThrow();
displayBook(book);
}
19
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public boolean existsBook2(Book book) {
Example<Book> bookExample = Example.of(book, ExampleMatcher.matchingAll().withIgnorePaths("genre", "price"));
return bookRepository.exists(bookExample);
}
19
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public boolean existsBook1(Book book) {
Example<Book> bookExample = Example.of(book);
return bookRepository.exists(bookExample);
}
19
Source : BookListener.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@PreUpdate
void onPreUpdate(Book book) {
System.out.println("BookListener.onPreUpdate(): " + book);
}
19
Source : BookListener.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@PostRemove
void onPostRemove(Book book) {
System.out.println("BookListener.onPostRemove(): " + book);
}
18
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@Transactional
public void updateBooks() {
Author author = authorRepository.findByName("Quartis Young");
List<Book> books = author.getBooks();
for (Book book : books) {
book.setIsbn("not available");
}
}
18
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void fetchBookByreplacedle() {
Book book1 = bookRepository.findByreplacedle("The book of swords");
// this is a Book
System.out.println(book1);
Book book2 = bookRepository.findByreplacedle("The beatles anthology");
// this is a Paperback
System.out.println(book2);
Book book3 = bookRepository.findByreplacedle("Anthology myths");
// this is an Ebook
System.out.println(book3);
}
18
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@Transactional
public void fetchAuthorByBook() {
Book book = bookRepository.findById(4L).orElseThrow();
Author author = authorRepository.findByBooks(book);
System.out.println("Fetched author: " + author);
}
18
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@Transactional
public void insertNewBook() {
Author author = authorRepository.fetchByName("Joana Nimar");
Book book = new Book();
book.setIsbn("004-JN");
book.setreplacedle("History Details");
// use addBook() helper
author.addBook(book);
authorRepository.save(author);
}
18
Source : MainApplication.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@Bean
public ApplicationRunner init() {
return args -> {
bookstoreService.persistTwoBooks();
Book book = bookstoreService.fetchFirstBookByNaturalId();
System.out.println(book);
};
}
18
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void displayAuthorsByAgeWithBooksAndPublishers(int age) {
List<Author> authors = authorRepository.findByAgeLessThanOrderByNameDesc(age);
for (Author author : authors) {
System.out.println("\nAuthor: " + author);
List<Book> books = author.getBooks();
System.out.println("No of books: " + books.size() + ", " + books);
for (Book book : books) {
System.out.println("Book: " + book.getreplacedle() + " published by: " + book.getPublisher());
}
}
}
18
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void displayAuthorsByAgeBetween20And40WithBooksAndPublishers() {
List<Author> authors = authorRepository.fetchAllAgeBetween20And40();
for (Author author : authors) {
System.out.println("\nAuthor: " + author);
List<Book> books = author.getBooks();
System.out.println("No of books: " + books.size() + ", " + books);
for (Book book : books) {
System.out.println("Book: " + book.getreplacedle() + " published by: " + book.getPublisher());
}
}
}
18
Source : MainApplication.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@Bean
public ApplicationRunner init() {
return args -> {
System.out.println("\n------------------- Joana Nimar's Books --------------------");
List<Book> detachedBooks = bookstoreService.fetchBooksOfAuthor("Joana Nimar");
detachedBooks.forEach(b -> System.out.println(b));
System.out.println("\n---------- Books of Joana Nimar updated in detached state------------");
// ,update first book replacedle
detachedBooks.get(0).setreplacedle("A History of Ancient Rome");
// remove second replacedle
detachedBooks.remove(1);
// add a new book
Book book = new Book();
book.setreplacedle("History In 100 Minutes");
book.setIsbn("005-JN");
detachedBooks.add(book);
detachedBooks.forEach(b -> System.out.println(b));
System.out.println("\n----------------- Merging books of Joana Nimar ----------------");
bookstoreService.updateBooksOfAuthor("Joana Nimar", detachedBooks);
System.out.println("\n----------------- Books of Joana Nimar After Merge ----------------");
List<Book> books = bookstoreService.fetchBooksOfAuthor("Joana Nimar");
books.forEach(b -> System.out.println(b));
};
}
18
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@Transactional
public void fetchBooksOfAuthorByIdAndAddNewBook() {
List<Book> books = bookRepository.fetchBooksOfAuthorById(4L);
Book book = new Book();
book.setIsbn("004-JN");
book.setreplacedle("History Facts");
book.setAuthor(books.get(0).getAuthor());
books.add(bookRepository.save(book));
System.out.println(books);
}
18
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@Transactional(readOnly = true)
public void fetchBooks() {
Book book = bookRepository.findById(7L).orElseThrow();
Book nextBook = book.getNextBook();
System.out.println("Fetched book with id 7: " + book);
System.out.println("Fetched book with next smallest price: " + nextBook);
}
18
Source : MainApplication.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@Bean
public ApplicationRunner init() {
return args -> {
Author author = bookstoreService.fetchAuthorWithBooksByName();
System.out.println("\nAuthor name: " + author.getName() + " Books: " + author.getBooks() + "\n");
Book book = bookstoreService.fetchBookWithAuthorByIsbn();
System.out.println("\nreplacedle: " + book.getreplacedle() + " author: " + book.getAuthor() + "\n");
};
}
18
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
private void displayBooks(List<Book> books) {
for (Book book : books) {
System.out.println(book);
System.out.println(book.getAuthor());
System.out.println(book.getAuthor().getPublisher() + "\n");
}
}
18
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
private void displayBook(Book book) {
System.out.println(book);
System.out.println(book.getAuthor());
System.out.println(book.getAuthor().getPublisher() + "\n");
}
18
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void displayBookByIdViaJoinFetch() {
// LEFT JOIN
Book book = bookRepositoryJoinFetch.findById(1L).orElseThrow();
displayBook(book);
}
18
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void displayBookByIdViaEnreplacedyGraph() {
// LEFT JOIN
Book book = bookRepositoryEnreplacedyGraph.findById(1L).orElseThrow();
displayBook(book);
}
18
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public boolean existsBook3(Book book) {
Example<Book> bookExample = Example.of(book, ExampleMatcher.matchingAny().withIgnorePaths("genre", "price"));
return bookRepository.exists(bookExample);
}
18
Source : BookListener.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@PreRemove
void onPreRemove(Book book) {
System.out.println("BookListener.onPreRemove(): " + book);
}
18
Source : BookListener.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@PrePersist
void onPrePersist(Book book) {
System.out.println("BookListener.onPrePersist(): " + book);
}
18
Source : BookListener.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@PostUpdate
void onPostUpdate(Book book) {
System.out.println("BookListener.onPostUpdate(): " + book);
}
18
Source : BookListener.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@PostPersist
void onPostPersist(Book book) {
System.out.println("BookListener.onPostPersist(): " + book);
}
18
Source : BookListener.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@PostLoad
void onPostLoad(Book book) {
System.out.println("BookListener.onPostLoad(): " + book);
}
17
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@Transactional(readOnly = true)
public void fetchBookWithAuthor() {
Book book = bookRepository.findByreplacedle("Anthology gaps");
Author author = book.getAuthor();
System.out.println(book);
System.out.println(author);
}
17
Source : MainApplication.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@Bean
public ApplicationRunner init() {
return args -> {
bookstoreService.newBookOfAuthor();
Book book = bookstoreService.fetchBookByAuthorId();
System.out.println(book);
};
}
17
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@Transactional
public void deleteBookOfAuthor() {
Author author = authorRepository.fetchByName("Alicia Tom");
Book book = author.getBooks().get(0);
// use removeBook() helper
author.removeBook(book);
}
17
Source : MainApplication.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@Bean
public ApplicationRunner init() {
return args -> {
bookstoreService.persistTwoBooks();
Book book = bookstoreService.fetchFirstBookByNaturalId();
System.out.println("\nFirst fetch:" + book);
Book bookAgain = bookstoreService.fetchFirstBookByNaturalIdAgain();
System.out.println("\nFetch again:" + bookAgain);
};
}
17
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void displayAuthorsWithBooksAndPublishersWithSpec() {
List<Author> authors = authorRepository.findAll(isAgeGt45());
for (Author author : authors) {
System.out.println("\nAuthor: " + author);
List<Book> books = author.getBooks();
System.out.println("No of books: " + books.size() + ", " + books);
for (Book book : books) {
System.out.println("Book: " + book.getreplacedle() + " published by: " + book.getPublisher());
}
}
}
17
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void displayAuthorsWithBooksAndPublishers() {
List<Author> authors = authorRepository.findAll();
for (Author author : authors) {
System.out.println("\nAuthor: " + author);
List<Book> books = author.getBooks();
System.out.println("No of books: " + books.size() + ", " + books);
for (Book book : books) {
System.out.println("Book: " + book.getreplacedle() + " published by: " + book.getPublisher());
}
}
}
17
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void displayAuthorsAndBooksByAgeAndGenre(int age, String genre) {
List<Author> authors = authorRepository.findByAgeGreaterThanAndGenre(age, genre);
for (Author author : authors) {
System.out.println("\nAuthor: " + author.getName());
List<Book> books = author.getBooks();
for (Book book : books) {
System.out.println("Book: " + book.getreplacedle());
}
}
}
17
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void displayAuthorsAndBooksByGenreAndAge(String genre, int age) {
List<Author> authors = authorRepository.findByGenreAndAgeGreaterThan(genre, age);
for (Author author : authors) {
System.out.println("\nAuthor: " + author.getName());
List<Book> books = author.getBooks();
for (Book book : books) {
System.out.println("Book: " + book.getreplacedle());
}
}
}
17
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public void displayBooksAndAuthors() {
List<Book> books = bookRepository.findAll();
for (Book book : books) {
System.out.println("Book: " + book);
System.out.println("Author: " + book.getAuthor());
}
}
17
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
public Book persistBook() {
Book book = new Book();
book.setIsbn("001-JN");
book.setreplacedle("A History of Ancient Prague");
return bookRepository.save(book);
}
17
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@Transactional
public void fetchAuthorsOfBook() {
Book book = bookRepository.findById(1L).orElseThrow();
Set<Author> authorsSet = book.getAuthors();
System.out.println("Authors ordered descending by name:\n" + authorsSet);
}
17
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@Transactional(readOnly = true)
public void displayBooksAndAuthors() {
List<Book> books = bookRepository.findAll();
for (Book book : books) {
System.out.println("Book: " + book.getreplacedle());
System.out.println("Author: " + book.getAuthor());
}
}
17
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@Transactional
public void insertNewBook() {
Author author = authorRepository.getOne(4L);
// or, less efficient since a SELECT is triggered
// Author author = authorRepository.findByName("Joana Nimar");
Book book = new Book();
book.setIsbn("003-JN");
book.setreplacedle("History Of Present");
book.setAuthor(author);
bookRepository.save(book);
}
17
Source : BookstoreService.java
with Apache License 2.0
from AnghelLeonard
with Apache License 2.0
from AnghelLeonard
@Transactional
public void removeBookOfAuthor() {
Author author = authorRepository.findByName("Alicia Tom");
Book book = bookRepository.findByreplacedle("The book of swords");
// use removeBook() helper
author.removeBook(book);
}
See More Examples