-->
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.  [ 6 posts ] 
Author Message
 Post subject: Second-level cache and updates
PostPosted: Fri Aug 20, 2004 11:36 am 
Beginner
Beginner

Joined: Mon Nov 24, 2003 5:39 am
Posts: 26
Location: France
Does the second-level cache have the intelligence to not issue an update statement when an unmodified object (which was previously loaded from cache) is reassociated with a session?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 7:24 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
you mean using update()

no, it is not that intelligent.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 4:12 am 
Beginner
Beginner

Joined: Mon Nov 24, 2003 5:39 am
Posts: 26
Location: France
Are there any alternatives?

We have a multi-page form workflow and want to avoid an update when the user has not modified data and clicks "back" or "next"


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 5:14 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
thomasvdv wrote:
Are there any alternatives?

We have a multi-page form workflow and want to avoid an update when the user has not modified data and clicks "back" or "next"

1). If you are using ehcache, you can tune timeToIdleSeconds and timeToLiveSeconds parameters for each cached class, for all other supported caches I think there is the same configs.
2). Another solution using of HttpSession or Statefull Session Bean to save intermediate data, but don't put very large data structures into HttpSessions.
3). some kind of onEdit javascript/event that marks the input like dirty and needed to reupdate.

_________________
Leonid Shlyapnikov


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 5:28 am 
Beginner
Beginner

Joined: Mon Nov 24, 2003 5:39 am
Posts: 26
Location: France
Wouldn't it work if I load the object to be updated from cache, apply the changes (which could be none) and perform call update() within the same transaction? The object loaded from cache would not be dettached in such a scenario and it would be considered equal when update() is called. Is this a correct assumption?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 6:00 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
thomasvdv wrote:
Wouldn't it work if I load the object to be updated from cache, apply the changes (which could be none) and perform call update() within the same transaction? The object loaded from cache would not be dettached in such a scenario and it would be considered equal when update() is called. Is this a correct assumption?

You don't need to call update for attached objects:
Code:
obj = (MyClass) session.get(id); // or find(...)
obj.setProperty(someValue); // modify or not modify
// session.update(obj); // object is already attached, you don't need to associate it with the session.
session.flush(); // flush changes, non dirty objects should not be flushed

It is OK scenario.

_________________
Leonid Shlyapnikov


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