Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. @Entity
  2. public class Book {
  3. @Id
  4. @GeneratedValue(strategy = GenerationType.AUTO)
  5. private Long id;
  6. private String title;
  7. private String isbn;
  8. private String publisher;
  9.  
  10. @ManyToMany
  11. @JoinTable(name = "author_book", joinColumns = @JoinColumn(name = "book_id"),
  12. inverseJoinColumns = @JoinColumn(name = "author_id"))
  13. private Set<Author> authors = new HashSet<>();
  14. }
  15.  
  16. @Entity
  17. public class Author {
  18.  
  19. @Id
  20. @GeneratedValue(strategy = GenerationType.AUTO)
  21. private Long id;
  22. private String firstName;
  23. private String lastName;
  24.  
  25. @ManyToMany(mappedBy = "authors")
  26. private Set<Book> books = new HashSet<>();
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement