aspose file tools*
The moose likes Object Relational Mapping and the fly likes Beginner needs help with hb caching strategy, Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Beginner needs help with hb caching strategy," Watch "Beginner needs help with hb caching strategy," New topic
Author

Beginner needs help with hb caching strategy,

Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
Hello All,

-I have three medium-sized tables. (Record count < 1000)

-The three tables are seldom updated.

-The three tables are updated from the outside and not from the hibernate app.

-I use tomcat 5.5 and the latest version of hibernate together with entity manager

-My three tables have no primary keys.

-Database access is prohibitively slow and I would like to be able to cache the three tables.

Which hibernate caching strategy would you advise?

Thanks in advance,

Julien.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10052
    
163

Originally posted by Julien Martin:
-The three tables are updated from the outside and not from the hibernate app.

Which hibernate caching strategy would you advise?



Since you mention that the tables will be updated from an external source and not the hibernate application, maintaing a cache by configuring Hibernate would not help you achieve this. You might have to implement (or use) some cache (ex: JBossCache) to cache this data in your application instead of relying on Hibernate caching.


[My Blog] [JavaRanch Journal]
Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
Do you think this would be ok?
"org.hibernate.cache.TreeCacheProvider"
Julien.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10052
    
163

Using this would mean that you are enabling second level cache of Hibernate and *relying on Hibernate* to maintain the cache. This would not work in your case because the data will be updated by some external source and Hibernate would be unaware of the changes to the data, leaving the cache in a stale state.
Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
thanks for replying!
Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
Hello Jaikiran Pai,
Just to let you know that I found some interesting info about a hibernate feature that you might want to know about: the query cache.
Julien.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10052
    
163

Query Cache and Hibernate Second level cache both help applications which rely on Hibernate updating the data. Here's a brief but good explanation about how these caches work Understanding Second-level cache and Query Cache. However if your data is being updated by an external source, you still might not find Query Cache useful. Did the query cache help you in the usecase which you mentioned above? Would be more than happy to know the solution
[ April 09, 2007: Message edited by: Jaikiran Pai ]
Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
Hello Jaikiran,
Thanks for the article. I went through it and found it of interest. I now know for certain that I need the query cache but can't get it working. I know I am missing something obvious.
Here is my post:
http://www.coderanch.com/t/217139/ORM/java/query-cache-work
Can you help?
Thanks in advance,
Julien.
Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
I solved the problem. I had forgotten to put my entity manager in session scope. Sorry for troubling you.
J.
 
 
subject: Beginner needs help with hb caching strategy,