[jboss-user] [JBoss Seam] - Re: how to use PropertyChangeListener on entity beans for dr

gavin.king@jboss.com do-not-reply at jboss.com
Wed Aug 15 16:21:32 EDT 2007


Email from Mark:

anonymous wrote : 
  | I chatted to the guy, on irc, he just didn't realise you can call
  | session.update( myObjHandle ) - and that the update( myObj ) call can
  | even be done via a hibernate save listener, so think he's all happy now.
  | No need to notify the engine each time a single property changes.
  | 
  | session.update( myObjectHandle ) actually works by using something
  | called "shadow facts". We proxy inserted objects and create a shallow
  | cache of each field value. When you call update it actually retracts
  | using the old cached field values.
  | 
  | You can turn shadow facts off, but then you cannot use session.update(
  | myObjectHandle) instead you have to call session.modifyRetract(
  | myObjectHandle) before the first setter is called, and
  | session.modifyInsert( myObjectHandle, myObject ) after the last setter
  | is applied. Turning shadow facts off improves performance about 10%,
  | depending on how many fields you have, and uses slightly more memory.
  | 
  | After we do 4.0, maybe we can look on how we can solve problems like
  | this, for better integration.  PropertyChangeListeners are not very
  | efficient, we don't really want to notify the engine each time a field
  | changed. In MVEL we have the following syntax:
  | modify ( person ) { age+= 1, location = "london" }
  | 
  | I call this a block setter. The engine is notified before the first
  | setter and after the last setter - i.e. it basically auto calls
  | modifyRetract and modifyInsert for you.
  | 
  | Anyway I'd be interested to hear ideas you have on this. Two I can think
  | of are hooking into the hibernate save() method and some how hooking
  | into a transaction block. So that at the start of the transaction block
  | all used facts are retracted from the network, and re-insert at the end
  | of the network; or just simply calling update( objectHandle ) at the end
  | of the transaction block.
  | 
  | In later issues we will track the actual fields changed, in a
  | consequence using MVEL, this allows for more efficient network
  | re-evaluation. maybe using AOP (like jgroups) we can achieve something
  | similar with seam and hibernate - although have to be sure that the cost
  | of the AOP stuff, isn't higher than the full network evaluation.
  |  

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4074574#4074574

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4074574



More information about the jboss-user mailing list