-->
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.  [ 2 posts ] 
Author Message
 Post subject: Second Level Cache - Load by identifier
PostPosted: Mon Jun 29, 2009 3:54 am 
Newbie

Joined: Thu Jan 08, 2009 9:23 am
Posts: 9
Hi,

I have implemented the second level cache for an entity.
Entity name com.msdw.onecrm.persistent.Team
cache usage is read-write

Below is my query:
Query q = session.createQuery( "from Team t where t.id = 'NC0000003'");
Team team = (Team)q.uniqueResult();
System.out.println( l.getName() );

However, above code always fires a query on database, I am expecting that the object should come from Second Level Cache since I am loading the object through its identifier.

Through SecondLevelCacheStatistics, I got the HitCount = 0, MissCount = 0, PutCount = 1

Please correct me if I am wrong or is there any other way to get the object from identifier.

Regards,
Sourabh

Please ignore it. i have got the solution.


Top
 Profile  
 
 Post subject: Re: Second Level Cache - Load by identifier
PostPosted: Mon Jun 29, 2009 9:27 am 
Regular
Regular

Joined: Thu Sep 06, 2007 2:22 am
Posts: 108
Location: Noida,India
To get the object form second level cache, first object should be there. if object, for what r u looking is not exist in the cache, then it go to database to retrieve that.

and you have to use
Quote:
get
or
Quote:
load
method to retrieve the object by identifier.

Like -
Quote:
Session session = ///get session
Team t = (Team) session.get(Team.class,'NC0000003');


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.