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: Update father on interceptor
PostPosted: Fri Oct 16, 2009 12:53 pm 
Regular
Regular

Joined: Tue Feb 17, 2009 5:13 am
Posts: 59
My model:

Code:
public class Father {
  Set<Son> sons = new HashSet<Son>();
  String name = null;
  Date lastSonModifyDate = null;
  // ... other fields and setters/getters
}
public class Son {
  Father father = null;
  String name = null;
  Date lastModifyDate = null;
  // ... other fields and setters/getters
}


Use case:

1. There is in DB a Father object with a Son object associated (bidir).
2. Load father from DB.
3. Update name field for father.
4. Update name field for son.
5. Persist father.

My interceptor first detects father updates (onFlushDirty). Then executes the onFlushDirty for the son. In this case, I update son.lastModifyDate and also father.lastSonModifyDate.

When execution ends, all updates are persisted except father.lastSonModifyDate. I think this is because father is in session and has been updated before son, so this entity overrides the changes done in onFlushDirty method for the son entity.

How could I achieve my mark (set father's lastSonModifyDate from son interceptor)?

Thanks.

_________________
Born to lose... live to win!


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.