In Java applications you should not call business logic in your entity models. You can set some values in @PrePersist, @PreUpdate in entity for example:
/**
* Sets createdAt before insert
*/
@PrePersist
public void setCreationDate() {
this.createdAt = new Date();
}
/**
* Sets updatedAt before update
*/
@PreUpdate
public void setChangeDate() {
this.updatedAt = new Date();
}
Or you can get generated primary key values in the @PostPersist method. But stored procedure processing belongs to your service. Your service should call a stored procedure and get results for further processing. You can't use @PostPersist, @PostUpdate and @PostRemove annotations in your service, but you can write afterSave(), afterRemove() methodes in your service to call a stored procedure and process the result of the called stored procedure.
Check this link for examples: How to call stored procedures in JPA