Search in sources :

Example 1 with AuthorBooksDto

use of io.micronaut.data.tck.entities.AuthorBooksDto in project micronaut-data by micronaut-projects.

the class BookRepository method saveAuthorBooks.

public void saveAuthorBooks(List<AuthorBooksDto> authorBooksDtos) {
    List<Author> authors = new ArrayList<>();
    for (AuthorBooksDto dto : authorBooksDtos) {
        Author author = newAuthor(dto.getAuthorName());
        authors.add(author);
        for (BookDto book : dto.getBooks()) {
            newBook(author, book.getTitle(), book.getTotalPages());
        }
    }
    authorRepository.saveAll(authors);
}
Also used : BookDto(io.micronaut.data.tck.entities.BookDto) ArrayList(java.util.ArrayList) Author(io.micronaut.data.tck.entities.Author) AuthorBooksDto(io.micronaut.data.tck.entities.AuthorBooksDto)

Aggregations

Author (io.micronaut.data.tck.entities.Author)1 AuthorBooksDto (io.micronaut.data.tck.entities.AuthorBooksDto)1 BookDto (io.micronaut.data.tck.entities.BookDto)1 ArrayList (java.util.ArrayList)1