@PreRemove

From CauchoWiki

Jump to: navigation, search


The @PreRemove annotation marks an entity's method as a callback before an entity is deleted from the database.

Applications can use @PreRemove to process the persistent state of an entity before it is removed from the database.

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

[edit] Definition

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