I have two related entities, say
@Entity
public class Book {
@ManyToOne
Shelf shelf;
}
@Entity
public class Shelf {
@OneToMany(mappedBy="shelf")
Set<Book> books;
}
If I fetch an empty shelf (no books), create and persist a new book to the shelf and then fetch that shelf again, its books collection is empty. When I run it with debug logging I see that Hibernate doesn't search for the shelf for the second time, it just returns it from the session cache, where it lies not knowing, that it's books collection has been updated.
How can I get rid of the effect and get the updated state of the shelf?
Thanks,
Artem.