• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate caching- Which caching to use for performance ?

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I'm working on java application, that runs in tomcat and uses hibernate orm to query oracle database.

There are many tables in which data is rarely changed. These data are only changed by a third party application. (Not the one on which I'm working).

I need to put these tables' data in cache. Which is the best cache to use ?
(Please don't recomend query cache as it has timestamp lock as its problem).

Help !!!
 
Ranch Hand
Posts: 218
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hibernate 2nd level cache.
 
amit attri
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply !!! But I there will be certain third party application that will be changing data (that i will put in second level cache). Will cache be able to invalidate data as data changes. I'm working on application that deals with money. Hence data is very critical.
 
Rishi Shehrawat
Ranch Hand
Posts: 218
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The cache will not be able to detect changes made directly to the database. In case you are able to intercept/detect changes made by third party application you can invalidate the cache, however i think that this will not be easy as third party will be updating the database directly using JDBC.
 
amit attri
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Q1 The third party application is updating data using Hibernate only. I can even modify code in third party app.
Can both cahe (of third party and my app) synchronize their data ? If yes, How can I do that ?

Q2 In case I use second level cache as you suggested.... I read about it that it makes very frequent invalidation. And also if data of one table is changed, then entire cache is refreshed. Is it true ?

 
Rishi Shehrawat
Ranch Hand
Posts: 218
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Q1 The third party application is updating data using Hibernate only. I can even modify code in third party app.
Can both cahe (of third party and my app) synchronize their data ? If yes, How can I do that ?


You can invoke method on cache to invalidate when external system updates data. The cache can expose a method for this via JMX.

Q2 In case I use second level cache as you suggested.... I read about it that it makes very frequent invalidation. And also if data of one table is changed, then entire cache is refreshed. Is it true ?


You have control over what part of cache you want to invalidate & the frequency of invalidation. Please refer to documentation provided by cache provider that you are planning to use.
 
amit attri
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm super naive in JMX.
Can you provide me a detailed documentation (beginner) to use JMX in case of multiple tomcat servers updating single oracle database server ? Is hibernate involved in this ?
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

amit attri wrote:Q1 The third party application is updating data using Hibernate only. I can even modify code in third party app.
Can both cahe (of third party and my app) synchronize their data ? If yes, How can I do that ?



You could configure your second level cache as "read - write". If the request is going via hibernate itself, the cache should synchronize the changes automatically.

Read-Write Details

However by relying on cached entities, you risk having an out-of-sync cache when an update happens in the database via a different request, so ensure all requests go via hibernate itself.

amit attri wrote:Q2 In case I use second level cache as you suggested.... I read about it that it makes very frequent invalidation. And also if data of one table is changed, then entire cache is refreshed. Is it true ?



force eh cache
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic