Skip to content

Instantly share code, notes, and snippets.

Created February 11, 2014 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/8933982 to your computer and use it in GitHub Desktop.
Save anonymous/8933982 to your computer and use it in GitHub Desktop.
Listener and EntityWithListener no JPA
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 {
@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