Hi!

The spec says (3.5.2):
"The PreUpdate and PostUpdate callbacks occur before and after the database 
update operations to entity data respectively." 

Does that mean that @PreUpdate should get called only before any real SQL 
update to the database?, or always if the entity got made dirty (but not get 
subsequently updated into the database)?

The phrase in question is "database update operations to entity data". Is the 
focus more on 'database' or on 'entity data'?


The situation is as following:

@Entity
@EntityListener(AuditListener.class)
public class Person {
  ...
  @OneToMany
  List<Address> addresses;
  ...

  public void addAddress(Address a) {
   addresses.add(a);
  }
}

This means that adding an address will render the Person entity dirty and it 
will subsequently get flushed. But of course there will be no database SQL 
UPDATE Person get executed but only a SQL INSERT ADDRESS...

Shall the EntityListener on the Person entity really get called in this case? 

PS: I can live with that, but I'd rather clarify the expected behaviour before 
doing my own 'non-collections dirty' detection for the AuditListener (which 
sets the modifiedBy and modifiedAt attributes).

txs and LieGrue,
strub





      

Reply via email to