-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Reading object out of the second level cache: HOWTO ??
PostPosted: Tue May 03, 2005 11:34 am 
Newbie

Joined: Tue Dec 14, 2004 8:30 am
Posts: 9
Hibernate version:
3

Hi,

Is there any way to avoid database access if the second level cache is filled already ?

What I do is an initial load of all the objects I want to work with during my session. If a class then tries to load an object which is not in the cache yet (using a load() ), hibernate does a database lookup again. Can this be disabled ?

So what I need is something like a load()-method which only returns objects found in the cache (ignoring DB updates).

Any idea ??

Cheers,
Dirk


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 03, 2005 11:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
The only way I can think of is a custom load listener. That actually should not be to difficult, since if you extend the default listener it has a method specifically for retreiving entities from the database which you could just override.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 03, 2005 7:26 pm 
Newbie

Joined: Tue Dec 14, 2004 8:30 am
Posts: 9
Thanks for the reply,

that's actually the same conclusion I came to. But how can I tell hibernate to use the custom load listener ? (stupid question ?)

Cheers,
Dixie


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 03, 2005 7:59 pm 
Newbie

Joined: Tue Dec 14, 2004 8:30 am
Posts: 9
It's me again,

an alternative approach I was thinking on is to get the EhCache out of the hibernate context (how ?) and ask the cache with the known name if it contains a given object.

But if I understand it right, the Cache.get(Object key) of EhCache does not take the Object itself as a parameter, right ?

Any idea on how to get the cache and ask it if it contains the given entity ?

Thanks in advance,
Dixie


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 03, 2005 11:53 pm 
Regular
Regular

Joined: Mon Sep 20, 2004 8:42 am
Posts: 58
Location: Boston, US
I have the very same requirements. I'm my use case I'm loading data from a flat file where I need to check on several conditions to determine if the data is valid and the check involves looking up other domain data which I've configured to be cached. My problem too is that if a cache lookup is not found, the query is executed against the database (thereby losing the benefit of having a cache) and this dramatically increases to overall import time.

Could you kindly provide more details on how this can be solved.

Thanks,
Sanjiv


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.