JPA2 @ManyToMany – A simple Standalone application

The many to many relationship is between Authors and Books. There could be many authos for a given book. And an author can write many books.
The book class looks something like this:


@Table(name = "BOOKS")
public class Book {


@GeneratedValue(strategy = GenerationType.IDENTITY)

@Column(name = "BOOK_ID")

private int id;

@Column(name = "BOOK_NAME")

private String name;

@ManyToMany(cascade = CascadeType.PERSIST)

@JoinTable(name = "BOOKS_AND_AUTHORS",

joinColumns = @JoinColumn(name = "BOOK_ID"),

inverseJoinColumns = @JoinColumn(name = "AUTHOR_ID"))

public List<Author> bookAuthors;