You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Javers Spring support uses JaversAuditableRepositoryAspect on Spring-Data @Repository classes for @JaversAuditable or the Spring-Data CrudRepository interface. If an exception is thrown from one of those methods, then JaversAuditableRepositoryAspect, which uses @After will still execute and try and perform a versioning. According to Spring AOP Docs, @After will always execute, regardless of if there was an exception thrown or not. @AfterReturning instead executes only if the method returns normally.
…hrown exceptions
Solution is to use @AfterReturning which only runs on a noraml method exit, and @AfterThrowing which checks if @transactional was used on the @repository method, and if noRollbackFor or noRollbackForClassName is configured (still commit even if these Exceptions/Throwables are thrown) and matches the current Throwable, still proceed with the versioning.
Javers Spring support uses JaversAuditableRepositoryAspect on Spring-Data
@Repository
classes for@JaversAuditable
or the Spring-DataCrudRepository
interface. If an exception is thrown from one of those methods, then JaversAuditableRepositoryAspect, which uses@After
will still execute and try and perform a versioning. According to Spring AOP Docs,@After
will always execute, regardless of if there was an exception thrown or not.@AfterReturning
instead executes only if the method returns normally.Here's the original StackOverflow question for reference.
The text was updated successfully, but these errors were encountered: