-->
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: How to reset/clear Hibernate QueryCache?
PostPosted: Tue Aug 28, 2007 8:40 am 
Newbie

Joined: Mon Apr 16, 2007 12:02 pm
Posts: 17
Hello,

I would like to know how to reset/clear Hibernate QueryCache?

I've found the method clear() into QueryCache class, but I do not know how to call it from a Session or a SesssionFactory?

Thanks and regards

Samuel


Top
 Profile  
 
 Post subject: That one is "clear".
PostPosted: Tue Aug 28, 2007 1:34 pm 
Newbie

Joined: Tue Aug 28, 2007 12:54 pm
Posts: 16
Location: Munich, Germany
In Hibernate, all important things are done on your instance of Session.
Maybe you'll find a
Code:
clear()
there, too ;-)

Optionally, what about closing and opening a new one ?

Cheers, Tom.

_________________
www.tomeicher.de


Top
 Profile  
 
 Post subject: more precisely
PostPosted: Tue Aug 28, 2007 2:10 pm 
Newbie

Joined: Mon Apr 16, 2007 12:02 pm
Posts: 17
Here is was is written on

http://www.hibernate.org/hib_docs/refer ... batch.html

"clear() the session regularly, to control the size of the first-level cache."

but what i would like is to clear the second level of cache (not the 1st level)

so how to do this?

regards

Samuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 03, 2007 8:23 pm 
Beginner
Beginner

Joined: Tue Apr 25, 2006 10:46 am
Posts: 28
This shud help.

http://forum.springframework.org/showthread.php?t=29691

Regards

Sam


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Wed Sep 12, 2007 4:13 am 
Newbie

Joined: Mon Apr 16, 2007 12:02 pm
Posts: 17
Thanks for this tip

I've also written the following

public static void evictEntity(String schemaName, String entityName) {
getSessionFactory(schemaName).evictEntity(entityName);
}

public static void evictQueries(String schemaName) {
getSessionFactory(schemaName).evictQueries();
}

@SuppressWarnings("unchecked")
public static void evictAll(String schemaName) {
evictQueries(schemaName);
Map metadata = getSessionFactory(schemaName).getAllClassMetadata();
for (Iterator i = metadata.values().iterator(); i.hasNext(); ) {
ClassMetadata classMetadata = (ClassMetadata) i.next();
evictEntity(schemaName, classMetadata.getEntityName());
}
}


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.