I have the following problem refreshing a list of objects:
Loading data with "createQuery(...).getResultList()" returns a list of objects. Now an object gets changed in the database by some other means. Refreshing the list of objects with the identical query fetches the objects from the database again but then sees that this object is already cached and returns the cached object (containing stale data).
In my case the query could use @Version to detect changes, but the version check is only done when the LockMode changes (which doesn't, as I just want to refresh the data displayed)
Calling refresh(obj) on the other hand for all objects in the list gives the correct result, but that is not an option as the number of objects could change too.
Any way to circumvent caching here or use the @Version attribute to detect the changes?
Info:
Hibernate Annotations 3.1b5, Entity Manager 3.1b3, Oracle DB
Code:
Code:
teps=(List<Tep>)Ejb3Util.createQuery("SELECT p FROM Tep p"
+" WHERE p.id.teid=:teid"
+" ORDER BY p.artnr")
.setParameter("teid",teid)
.getResultList();