breako wrote:
Hi,
I wish to put a persistence flag in my JPA entities to indicate the JPA entity is persistent.
This flag will begin at false to indicate the entity is not persistent. If the application persists and commits this entity it should go to true to indicate entity is persistent.
I need a hook to set this flag to true.
I can't use @PrePersist because this gets invoked at the persist method invocation. The problem here is commit() may never get called.
I can't use @PostPersist because this happens after the entity gets inserted in the database which means the wrong value for the flag will get inserted in the database.
any ideas?
Thanks
Hi,
I solved this by using postPersist() event and not making the variable persistable.
This is this just a utiility API in our current architecture, we are migrating to JPA hibernate.
Rgds