-->
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: Interception order
PostPosted: Tue Oct 13, 2009 3:04 pm 
Regular
Regular

Joined: Tue Feb 17, 2009 5:13 am
Posts: 59
Hi all.

I have the following (piece of) model:
Code:
@Entity
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
@Table(name="text")
public class Text implements Serializable {
   protected Set<Subtext> subtexts = new HashSet<Subtext>();
   @OneToMany(mappedBy="text")
   @Cascade(value = {CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.DELETE_ORPHAN })
   private Set<Subtext> getSubtexts() {
      return subtexts;
   }
   public void setSubtexts(Set<Subtext> subtexts) {
      this.subtexts = subtexts;
   }
}

@Entity
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
@Table(name="subtext")
public class Subtext implements Serializable {
   private Text text = null;
   @ManyToOne
   @JoinColumn(name="text_uuid")
   @NotNull
   public Text getText() {
      return text;
   }
   public void setText(Text text) {
      this.text = text;
   }
}


I use an interceptor to validate some fields. When I persist a Text objects with any Subtext object related to (Text.subtexts), the interceptor first catch Text entity, and then Subtext entity.

I need to update a date in Text when a Subtext is modified. I do that in the interceptor, but it does not work due to when Subtext is intercepted, Text yet has been processed and it is not intercepted again, even if my onFlushDirty method returns true.

Note that:
- if I load a Subtext from DB and I modify it, the interceptor detects, in this order, the Subtext update and the Text update (I insist, in this order)
- but, if I load a Text from DB and I modify one of its Subtexts, then the interception order is: first Text, then Subtext.

In general, I need:
    to be able to raise an entity interception within an interceptor's method (for a different entity).
    to determine the interception order.

Any idea?

_________________
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.