em.persist(author);
}
System.err.println("Creating " + nBook + " new Books");
System.err.println("Linking at most " + nAuthorPerBook + " Authors per Book");
for (int i = 1; i <= nBook; i++) {
Book book = new Book(Randomizer.randomString(4,2),
"Book-" + i,
Randomizer.random(priceMin, priceMax),
Randomizer.random(stockMin, stockMax));
List<Author> authors = Randomizer.selectRandom(allAuthors,
Math.max(1, Randomizer.random(nAuthorPerBook)));
for (Author author : authors) {
author.addBook(book);
book.addAuthor(author);
}
em.persist(book);
}