I have a JPA @Entity class which uses a @PrePersist for quite a while now. Today I wanted to add some functionality where I need the ID of that entity. This ID is generated during persist by a HIBERNATE_SEQUENCE in the database. It is usually set after em.persist(entity).
For some unknown reason the @PrePersist method is triggered... while @PostPersist simply never fires:
@Entity
public class MyEntity {
@PrePersist
protected void onCreate() {
System.out.println("ExtendedEntity.onCreate()");
}
@PostPersist
protected void afterCreate() {
System.out.println("ExtendedEntity.afterCreate()");
}
}
I'm using a JBoss v4.2 environment with Java v7+, Hibernate v3.3.1.GA and Seam v2.2.2.Final...
Are there any hidden requirements for @PostPersist to fire?