Having an entity with more than one {{@OneToMany}} associations with {{cascade = CascadeType.ALL}}, if I invoke {{session.refresh()}} on that entity, one (and only one) of these associations gets loaded.
Example, with this model: { { code:java} @Entity @Table(name = "invoice") public class Invoice { @OneToMany(mappedBy = "invoice", cascade = CascadeType.ALL) private List<Line> lines; @OneToMany(mappedBy = "invoice", cascade = CascadeType.ALL) private List<Tax> taxes; ... } {code } }
When doing: Session s = openSession(); Invoice invoice = s.get(Invoice.class, 1); s.refresh(invoice);
Not only invoice is refreshed from DB, but also its lines, although taxes do not.
I’d expect not to have initialized any of its associations, but in any case not just one of them (1st one?).
[Here a test case to reproduce it|https://github.com/alostale/hibernate-test-case-templates/tree/refresh-association/orm/hibernate-orm-5]. |
|