Win a copy of The Business Blockchain this week in the Cloud forum!
  • 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?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic