Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joao-parana/8934241 to your computer and use it in GitHub Desktop.
Save joao-parana/8934241 to your computer and use it in GitHub Desktop.
package model.entity;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Id;
@Entity @EntityListeners(MyListener.class)
public class MyEntityWithListener {
@Id
private long id;
}
/* Agora o Listener */
package model.entity;
import javax.persistence.PostLoad;
import javax.persistence.PostPersist;
import javax.persistence.PostRemove;
import javax.persistence.PostUpdate;
import javax.persistence.PrePersist;
import javax.persistence.PreRemove;
import javax.persistence.PreUpdate;
public class MyListener {
public MyListener() {
}
@PrePersist
void onPrePersist(Object o) {
}
@PostPersist
void onPostPersist(Object o) {
}
@PostLoad
void onPostLoad(Object o) {
}
@PreUpdate
void onPreUpdate(Object o) {
}
@PostUpdate
void onPostUpdate(Object o) {
}
@PreRemove
void onPreRemove(Object o) {
}
@PostRemove
void onPostRemove(Object o) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment