-->
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.  [ 4 posts ] 
Author Message
 Post subject: Querying and Updating a cache of Objects
PostPosted: Sun Aug 01, 2004 9:58 pm 
Beginner
Beginner

Joined: Fri Jul 30, 2004 2:53 pm
Posts: 33
Location: Washington, DC
Say I have a DAO method like this:

public Collection getBlogs() throws Exception {
Session session = sesFac.openSession();
List blogs = session.find("from Blog");
session.close();
return blogs;
}

1. How do I get this to be cached, so that this only executes a DB query the first time the method is executed?

2. If I can get the getBlogs method to loads all the blogs from the DB into a cache, how can I create another method that gets a specific blog from the cache?

3. Let's say I have another method that updates the blog with id = 5. Is there a way for me to invalidate/reload just the blog with id = 5? If not, how do invalidate the whole cache?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 01, 2004 10:01 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Did you read the rest of the documentation, esp. the chapter about caching and performance?

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 01, 2004 10:25 pm 
Beginner
Beginner

Joined: Fri Jul 30, 2004 2:53 pm
Posts: 33
Location: Washington, DC
christian wrote:
Did you read the rest of the documentation, esp. the chapter about caching and performance?

I assume you are talking about Chapter 14? I couldn't figure out how any of the caches their relate to this example. Session Cache just caches data within a session, right? I need to cache the data in one session and then get that data from another. Does the 2nd level or the query cache do that for me?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 02, 2004 3:41 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Yes.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.