Class BookRepository

java.lang.Object
lt.viko.eif.jguscia.services.BookRepository

public class BookRepository extends Object
Repository responsible for storing book data in the H2 database.

This class receives Books objects and inserts their data into the database tables <code>books</code> and <code>book_genres</code>.

  • Constructor Details

    • BookRepository

      public BookRepository(H2Initialization db)
      Creates a new repository instance using the provided database initializer.
      Parameters:
      db - service responsible for database connection management
  • Method Details

    • saveAll

      public void saveAll(Books books) throws SQLException
      Saves all books and their associated genres into the database.

      Each book is inserted into the <code>books</code> table, and its genres are inserted into the <code>book_genres</code> table.

      Parameters:
      books - container object holding a list of books to persist
      Throws:
      SQLException - if a database access error occurs