-->
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.  [ 1 post ] 
Author Message
 Post subject: Fast polymorphic Session.get or Session.load with l2 cache
PostPosted: Thu Mar 20, 2008 11:13 am 
Newbie

Joined: Fri Aug 29, 2003 8:34 am
Posts: 7
We are using hibernate 3.2.5GA with level 2 cache turned on for most objects. Our ids are unique across all tables so most of our code just does Dao.get(id).

At the moment we have slow kludge to load the appropriate object by id using the HQL: "select obj from BaseClass obj where id=:id"

We don't mind the cost of this when the object is not in any cache but it seems a shame not to look in the caches first.

Assuming Session.load and Session.get don't do negative caching is there a supported way of peeking into the caches to see if our object is already there?

I can see how I can cast to SessionFactoryImpl, get all the caches, cobble together CacheKeys for each concrete entity class ... but I doubt my tech lead will be impressed.

btw We assume Session.get/load(BaseClass.class, id) is meant to fail with error about BaseClass not being mapped (we use @MappedSuperclass annotation).

Many thanks, sorry such a long posting.

Sam


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

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.