Refresh a list of domain objects in EJB 3

I have code like this in my Session Bean

Query query = em.createNamedQuery("MyEntity.findAll");

return query.getResultList();

But sometimes I get stale data.

My understanding is that I need to call em.refresh() on any object to reload it. Is there something I can set to have that done automatically without having to iterate through the list and refresh each object? That seems awfully expensive to me.

[492 byte] By [whartunga] at [2007-11-26 15:11:08]
# 1
I'm not an EJB 3 expert, but I believe you can use setHint to instruct your implementation to not query the cache for a given statement. I personally haven't had problems with read all queries not reflecting updates- is your datasource being updated from outside the container?
rvflannerya at 2007-7-8 9:02:01 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Yes, I should have mentioned that the data was being updated out of the container. Otherwise, it's been working fine. I'll see if I can find anything about hints.Thanx!
whartunga at 2007-7-8 9:02:01 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...