I have 2 referenced entity Author and Book and have reference many2one=>one2many between it, i have a problem with realization? when in go to /authors
i get all authors with his books inside but inside each book have his author (with all own books) and vice versa
Problem in one point, i need get
/authors
- all authors without his books
/author/{id}
with all his books (inside books dont need author)
/books
all books with authors inside book (but inside book dont need author)
/book/{id}
book with author (without his books inside)
@Entity(name = "Author")
@Table(name = "authors")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class Author {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name = "title")
private String title;
@Column(name = "description")
private String description;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "author", cascade = CascadeType.ALL)
private List<Book> books; ....
and
@Entity
@Table(name = "books")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class Book{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name = "price")
private double price;
@Column(name = "title")
private String title;
@Column(name = "description")
private String description;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "author_id")
private Author author; ....