@PreUpdate

From CauchoWiki

Jump to: navigation, search


The @PreUpdate annotation marks an entity's method as a callback before updates to an entity are saved to the database.

Applications can use @PreUpdate to process the persistent state of an entity before changes are saved to the database.

 import javax.persistence.*;
 
   @Entity
   public class MyEntity {
       @Id getId() { ... }
 
       @PreUpdate
       public void beforeUpdate()
       {
          ...
       }
       
       ...
   }

[edit] Definition

 @Target(METHOD)
 @Retention(RUNTIME)
 public @interface PreUpdate {
 }
Personal tools