-->
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: 2nd level cache question
PostPosted: Thu Oct 15, 2009 3:54 am 
Beginner
Beginner

Joined: Mon Dec 17, 2007 11:08 pm
Posts: 47
hi,

I had 2 entity which is USER and ITEM .
the relationship is USER can have many ITEM , but one ITEM only belong to one USER, and I make it bi-direction without join table.
both user and item is 2nd level cache enabled.

in my web app, i use spring's openSessionInView Interceptor and i have a page query single item which link to user's information like this :

item.getName();
....
item.getUser().getEmail(); //get the item's user email, if omit this, not SELECT USER statement hit.

my problem is when 2nd level cache enabled, ITEM is cache (so no SQL hit) when i request the item page, but it always follow by a SELECT USER statement, and if i comment the code which is "item.getUser().getEmail();", no SELECT USER statement hit. (mean the select is cause when i get run this code)

so it seem like USER that belong to this ITEM is not get from 2nd level cache.

My question is:
1) seem like the user object is not cache, so it execute an SQL statement every time when i request the item page.
2) if the relationship is inverse, will hibernate fetch the inverse object in 2nd level first ? (i though should be.. but seem like not happening)

any idea ?

kiwi

_________________
happy hacking !


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.