Get all session-cached objects in Hibernate

I have a method that does HQL using org.hibernate.Query.executeUpdate()and modifies some rows in a database. If some of the affected query strings have been preloaded into the current session (for example, using Session.get()), they are now outdated and need to be updated.

But I want this method not to depend on the previous work with the session, and not to track all loaded objects that may be affected in order to update them later. Is it possible with Hibernate to retrieve and iterate objects in a level 1 cache?

+4
source share
1 answer

, :

Map.Entry<Object,EntityEntry>[] entities = ((SessionImplementor)session).getPersistenceContext().reentrantSafeEntityEntries()
+1

All Articles