From your description, you are probably using Hibernate 2nd level cache (a cluster or JVM-level cache) and when you update the database directly, you obviously bypass Hibernate's API and Hibernate does not get the opportunity to empty the cache so that it can get refreshed.
If you want to avoid having to restart your server, either avoid manual updates or explicitly tell Hibernate to empty the relevant parts of the cache after a manual update so that data will get reloaded. You can do this using the various overloaded evict()
methods at the SessionFactory
level.
From the Hibernate documentation:
...
For the second-level cache, there are
methods defined on SessionFactory for
evicting the cached state of an
instance, entire class, collection
instance or entire collection role.
sessionFactory.evict(Cat.class, catId); //evict a particular Cat
sessionFactory.evict(Cat.class); //evict all Cats
sessionFactory.evictCollection("Cat.kittens", catId); //evict a particular collection of kittens
sessionFactory.evictCollection("Cat.kittens"); //evict all kitten collections
Of course, this will require some knowledge of what is cached in your application and of what gets updated by your client. But someone must know this.
References
- Hibernate Core Reference Documentation