About Question enthuware.oce-jpad.v6.2.422 :

Moderator: admin

Post Reply
__JJ__
Posts: 125
Joined: Thu Jul 05, 2018 6:44 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.422 :

Post by __JJ__ »

himaiMinh wrote:
Mon Jul 03, 2017 2:23 pm
One more note about some previous posts here. People may get confused about when PreRemove and PreUpdate are called.

PreUpdate is called before the entity's update is committed/flushed to the database and PostUpdate is called after the update is committed...
PreRemove is called when the em.remove(entityA) is called and PostRemove is called when entityA is removed from the database when the transaction is committed.
Remove is used within a transaction.

I hope this note can help people to clarify their confusion between the lifecycle callback methods of update and remove.
No this is not true.
Firing of a PostPersist event does not indicate that the entity has committed successfully to the database because the transaction in which it as
persisted may be rolled back after the PostPersist event but before the transaction successfully commits....As with the PostPersist lifecycle event, the
postRemove event does not guarantee success. The enclosing transaction may still be rolled back....The PostUpdate callback occurs right after the
database update. The same potential for rollback exists after PostUpdate callbacks as with PostPersist and PostRemove.
The spec specifies the postXXX callback methods as occurring when XXX is invoked or upon a flush, but that's a flush, not a commit.

__JJ__
Posts: 125
Joined: Thu Jul 05, 2018 6:44 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.422 :

Post by __JJ__ »

What is strange is that remove followed by merge causes an IllegalArgumentException:

Code: Select all

Exception in thread "main" java.lang.IllegalArgumentException: org.hibernate.ObjectDeletedException: deleted instance passed to merge
but the remove itself seems not to be successful (even accounting for the fact that a "successful" remove could be rolled back) because the @PostRemove ELCM is not triggered before the merge failure. So delete->merge causes an exception where the deletion is blamed for the failure of the merge, but the deletion itself seems not to have completed pre-commit in the first place.

I have tested this with various SOPs and of course the annotated ELC methods.

Post Reply

Who is online

Users browsing this forum: No registered users and 55 guests