• Post Reply Bookmark Topic Watch Topic
  • New Topic

Entity lifecycle listeners behave differently

Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When using an entity lifecycle listener with the lifecycle method @PrePersist and/or @PreUpdate I get a RollbackExpection in which I can get the original Exception by calling the method getCause on the RollbackException. I understand this. The thrown exception is catched by the persistence provider and then thrown as a RollbackException, because the transaction is rolled back by the persistence provider.

Only when I use a entity life cycle listener with the annotation @PreRemove I get the original exception and have to rollback the transaction by hand.

Why is this different?

Curse your sudden but inevitable betrayal! And this tiny ad too!
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!