-->
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: hibernate cache behaviour
PostPosted: Tue Nov 03, 2009 9:33 am 
Newbie

Joined: Mon Nov 02, 2009 9:03 am
Posts: 3
Hi,

I have the following use case:

I've some entity cofigured to use second level cache (ehcache is the provider). Is persisting a new instance of that entity will automatically update the cache with it (for future select using pk)?

A check I made says no - I saw that the first fetch after the persist still hit the db, and future fetches indeed got the entity from the cache.

Is this the expected behaviour or its possible to update cache along with the persisting?

Thanks.


Top
 Profile  
 
 Post subject: Re: hibernate cache behaviour
PostPosted: Tue Nov 03, 2009 10:07 am 
Beginner
Beginner

Joined: Tue Nov 03, 2009 9:38 am
Posts: 24
I'm not sure but I'd say the cache does not contain that new entity and it will only be put into the cache if you execute a select query.
Thus the first query will hit the database and the entity will be put into the cache. If you'd only persist the entity but never read it again (or not in the "near" future) you'd not need it to reside in the cache.


Top
 Profile  
 
 Post subject: Re: hibernate cache behaviour
PostPosted: Tue Nov 03, 2009 10:15 am 
Newbie

Joined: Mon Nov 02, 2009 9:03 am
Posts: 3
This indeed suites my observations. Is there a way to put the entity in the cache manually?


Top
 Profile  
 
 Post subject: Re: hibernate cache behaviour
PostPosted: Tue Nov 03, 2009 10:17 am 
Beginner
Beginner

Joined: Sun Jul 12, 2009 9:53 am
Posts: 21
If the entity contains references to other tables, they are obviously not loaded if you just persist this new instance.

Maybe this could also be one of the reasons.


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.