I'm learning EJB3 and JPA and this might be an embarassingly stupid question. I'm following the conventions of injecting an entity manager factory into by stateless bean and creating an entity manager on initialization and closing it upon destruction.
This means that my one-to-many relationship crosses concurrent entity managers since it doesn't make sense to put both User (one) and Auction (many) operations into the same EJB bean.
The problem is that I can save a one-to-many relationship in the Auction bean but I don't see it via user.find() unless I immediately follow it with em.refresh(user).
Is there a way around this, e.g., having a shared entity manager cache? Calling refresh() hits the database so I would prefer to avoid it if possible.
This means that my one-to-many relationship crosses concurrent entity managers since it doesn't make sense to put both User (one) and Auction (many) operations into the same EJB bean.
The problem is that I can save a one-to-many relationship in the Auction bean but I don't see it via user.find() unless I immediately follow it with em.refresh(user).
Is there a way around this, e.g., having a shared entity manager cache? Calling refresh() hits the database so I would prefer to avoid it if possible.