Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Entity
- public class Book {
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- private Long id;
- private String title;
- private String isbn;
- private String publisher;
- @ManyToMany
- @JoinTable(name = "author_book", joinColumns = @JoinColumn(name = "book_id"),
- inverseJoinColumns = @JoinColumn(name = "author_id"))
- private Set<Author> authors = new HashSet<>();
- }
- @Entity
- public class Author {
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- private Long id;
- private String firstName;
- private String lastName;
- @ManyToMany(mappedBy = "authors")
- private Set<Book> books = new HashSet<>();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement