First, what type of caching are you using (read-only, nonstrict-read-write, or read-write)? This has a big impact on the behavior of the cache. Additionally, are you using a query cache, or loading by identifier? This also has an impact on how the cache behaves
Second, consider that that your database is only one resource in your application. If Hibernate forced queries to block until the initial query completed execution an populated that cache, you'd have n-number of requests tying up your app server.
Two possible solutions for you:
1.) Preload your most frequently used cached data on startup. This will mimize the behavior your seeing. This can be done by executing a query to load the entities in question.
2.) increase the timeout on your connection pool so that callers will block longer until connection is returned to the pool.
Ryan-
_________________ Ryan J. McDonough
http://damnhandy.com
Please remember to rate!
|