Closed lawynnj closed 3 years ago
@knjk04 thoughts?
@lawynnj Thanks for bringing this up and for the detailed issue description (this made debugging a lot easier)!
You're right that publisher_book
should not be empty.
Publisher publisher = new Publisher("Bloomsbury");
publisherRepository.save(publisher);
Book book1 = createBook(
"Harry Potter and the Philosopher's stone",
"Philosopher's stone blurb",
1997,
"9781408810545"
);
bookRepository.save(book1);
publisher.addBook(book1);
The issue is that we're saving the publisher before adding the book. I'll create a patch for this shortly
Describe the bug When the BooksApiApplication is run the database is seeded with some data.
The code that does the seeding: https://github.com/Project-Books/books-api/blob/f44b0d03dad1f2a131acbe14f7439808939be173/src/main/java/com/karankumar/booksapi/BooksApiApplication.java#L45
The book and publisher tables are seeded correctly, but the
publisher_book
table is not. When running a select query on thepublisher_book
table it returns nothing. See below:To Reproduce Steps to reproduce the behavior:
select * from publisher_book;
Expected behavior Running
select * from publisher_book;
should return the following:Desktop (please complete the following information):
Additional context There might be an issue with the model classes and how the relationships are defined.