• 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

When should Hibernate cache be used?

 
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

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.

-Cheers
Rama
 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rama,

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 ]
 
Rama Krishna
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

"How many instances of XyzDAO class is allowed in your application"



I really have no idea when you asked how many instances of this class are allowed. Are you still referring with respect to the cache context or is this something else all together?

If it cache, yes any number of instances can access the same cache and you can set whether its read-only or read-write and so on.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

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.

John
 
Elizabeth King
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by John Grath:


... turn the entire caching mechanism off. ...



I think it is the safest way to go.
 
reply
    Bookmark Topic Watch Topic
  • New Topic