basically my question is if there are any concerns (performance wise etc.) setting the scope of a seam managed persistence context to PAGE instead of the default one CONVERSATION? I ask this because in my application I observe the occurrence of stale data when multiple users (or multiple tabs) edit or view the same entities.
Consider the following scenario: I use a seam managed persistence context (default scope this time) injected into a stateless session bean to manage let's say Lecture entities. I open two tabs in my browser with two different long-running conversations being active. In tab 1 I display a list of lectures using a normal JPA query result list that was returned by one method of the stateless session bean (which, again, uses a @Injected EntityManager). In tab 2 I edit an entity of the list and also pass it to one of the methods of the stateless session bean (and this as well uses its own @Injected EntityManager to save the entity). Having saved the entity in tab 2 everything is displayed quite fine in this conversation and also the database is updated with the new values. So far so good.
However, reloading tab 1 with the same conversation id in place now does not fetch the updated entity from the DB again, which seems pretty odd to me.
At first I plugged in my eclipse debugger and checked that indeed the entity manager (aka query.getResultList()) returns stale data. While debugging I also executed entityManager.refresh(lecture) on the updated entity and after that the result was fine, the entity was refreshed with the correct data that was inserted in tab 2. While this would work, I think it is a pretty bad idea to refresh each entity in a result list with possibly a hundred of objects.
Thus, I tried setting the scope of the seam managed persistence context to PAGE which helped out as well. Now, seam injects a new entity manager instance on each request and this one fetches up-to-date data from the DB as expected.
So again, my questions: is this the right behavior of the managed persistence context? I've never seen anyone else setting the scope of the seam managed persistence context to something else than the default, but how do they achieve consistent data across different conversations? Maybe some query hints could solve the problem as well? Do you have any idea (using Hibernate Persistence)?
Thanks a lot for your input!