Browse Source

Update sample book information

Signed-off-by: Pekka Helenius <fincer89@hotmail.com>
v0.0.1-alpha
Pekka Helenius 4 years ago
parent
commit
26de2e5846
2 changed files with 20 additions and 8 deletions
  1. +19
    -6
      bookstore/src/main/java/com/fjordtek/bookstore/BookstoreApplication.java
  2. +1
    -2
      bookstore/src/main/java/com/fjordtek/bookstore/model/CategoryRepository.java

+ 19
- 6
bookstore/src/main/java/com/fjordtek/bookstore/BookstoreApplication.java View File

@ -30,15 +30,28 @@ public class BookstoreApplication extends SpringBootServletInitializer {
commonLogger.info("Add new categories to database");
Category horror = new Category("Horror");
Category fantasy = new Category("Fantasy");
categoryRepository.save(horror);
categoryRepository.save(fantasy);
categoryRepository.save(new Category("Horror"));
categoryRepository.save(new Category("Fantasy"));
categoryRepository.save(new Category("Sci-Fi"));
commonLogger.info("Add new sample books to database");
bookRepository.save(new Book("Book 1 title", "Book 1 author", 2020, "1231231-12", 40.00, horror));
bookRepository.save(new Book("Book 2 title", "Book 2 author", 2005, "3213221-3", 20.17, fantasy));
bookRepository.save(new Book(
"Bloody Chamber",
"Angela Carter",
1979,
"1231231-12",
18.00,
categoryRepository.findByName("Horror").get(0)
));
bookRepository.save(new Book(
"The Witcher: The Lady of the Lake",
"Andrzej Sapkowski",
1999,
"3213221-3",
19.99,
categoryRepository.findByName("Fantasy").get(0)
));
commonLogger.info("------------------------------");
commonLogger.info("Sample categories in the database");


+ 1
- 2
bookstore/src/main/java/com/fjordtek/bookstore/model/CategoryRepository.java View File

@ -8,7 +8,6 @@ import org.springframework.data.repository.CrudRepository;
public interface CategoryRepository extends CrudRepository<Category, Long> {
// Handles both INSERT and UPDATE queries
List<Category> findById(String name);
List<Category> findByName(String name);
}

Loading…
Cancel
Save