I have a Customer class defined like this:
@Entity
public class Customer {
//...
@OneToMany(mappedBy = "customer", orphanRemoval = true, FetchType.EAGER)
@MapKey(name = "name")
private Map<String, Operation> operationMap = new HashMap<String, Operation>();
My GUI application retrieves this customer through an EJB and then updates the customer and/or its operations. The problem is that whenever the operationMap collection is traversed, new proxies of Operation entities are created and this creates a problem for GUI components. Some are still bound to old proxies, while some are bound to new proxies.
How do you propose to solve this problem? Try to traverse the operationMap only once? Is there a way to limit creation of new proxies somehow?
I’m using EclipseLink JPA (Glassfish AS).
It was actually a bug in my managed bean. A method was called by accident that fetched Customer entity even after initial page load, thus every time creating new detached
Customerentities.