Hi I have a relation like this in BookEO and BookAreaEO classes respectively. Now, I wanted to understand what is the purpose of mappedBy and how I can write a query like below in BookEO using JPA
select * from book b where exists (
select book_id from book_report_area ba
where b.book_id = ba.book_id and ba.subject_area_id=200);
// BookEO.java
Set<BookArea> bookAreas;
@Override
@PrivateOwned
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "book", targetEntity = BookAreaEO.class, orphanRemoval = true)
public Set<BookArea> getBookAreas() {
return bookAreas;
}
// BookAreaEO.java
Book book;
@Override
@ManyToOne(fetch = FetchType.LAZY, targetEntity = BookEO.class, optional = false)
@JoinColumn(name = "BOOK_ID", nullable = false)
public Book getBook() {
return book;
}