Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g (

Part Number E13981-01
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Index
Go to Feedback page
Contact Us

Go to previous page
Go to next page
View PDF

Configuring a Life Cycle Callback Method on a JPA Entity

You can specify a JPA entity class method as a callback method for any of the following life cycle events:

The entity class method must have the following signature:

int <METHOD>()

The entity class method can have any method name as long as it does not begin with ejb.

For more information, see the following:

Using Annotations

You can specify a JPA entity class method as a life cycle callback method using any of the following annotations:

  • @PrePersist

  • @PostPersist

  • @PreRemove

  • @PostRemove

  • @PreUpdate

  • @PostUpdate

  • @PostLoad

Example 7-30 shows how to use the @PrePersist annotation to specify JPA entity class method initialize as a life cycle callback method.

Example 7-30 @PrePersist

public class Project implements Serializable {
    @Column(name="PROJECT_ID", primaryKey=true)
    public Integer getId() {
         return id;
    public int initialize() {