Let's say I have two entities:
@Entity
public class Customer implements Serializable {
...
@OneToMany(cascade=ALL, mappedBy="customer")
public Set<Order> getOrders() {
return orders;
}
...
}
@Entity
public class Order implements Serializable {
...
@ManyToOne
@JoinColumn(name="CUST_ID", nullable=false)
public Customer getCustomer() {
return customer;
}
...
}
Then, I'm persisting Customer entity, and after that, Order entity with reference to previously added Customer. When I retrieve this customer from database, and call getOrders, it returns empty set. Is it normal behaviour? If it is, what can I do to automatically refresh this set when I add new Order entity?