If I load the data from the DB into the Hibernate classes and let Hibernate cache them to improve the performance, it may create an inconsistency problem when someone updates the DB using a different tool (such as SQLPlus). How do Hibernate or other OR frameworks handle this type of problem? [ March 25, 2008: Message edited by: Elizabeth King ]
As new as I am to Hibernate, I asked myself the same question. Anyways, I was wondering what you meant by "letting hibernate cache". I see that there are two types of cache, first level and second level, both of which seem to have their own different use.
I think that the First level is available by default associated with the session and this saves the number of transactions by updating only at the end of a transaction.
The second level is what I have been exploring as it works at the Session Factory level binding to the application and not to a particular user. I used EHCACHE initially to see how much it can help but I found 2nd level cache is of not much use in my case as fine tuning my HQL queries and optimizing the logic did most of the job and so avoided 2nd level cache all together.
A quick googling on "improving performance using hibernate cache" would take you to very decent articles that will explain why and when you should be using hibernate cache.
Let's say you are building an Hibernate XyzDAO class and your application can handle multiple user sessions. How many instances of XyzDAO class is allowed in your application? [ March 25, 2008: Message edited by: Elizabeth King ]
Most architectures which require changes from different data sources must either refresh the specific object from the database or turn the entire caching mechanism off. This is a common problem with both Toplink and Hibernate. Simple answer is to reload object you expect to be updated from external systems. Most enterprise systems require this.