Answer the question
In order to leave comments, you need to log in
Why doesn't the @PreRemove annotation work for me?
I write integration tests for services with an in-memory base ( h2
). Services do not contain any logic and simply call similar methods from the DAO. Services also have annotations @Transactional
(at the class level). Methods for reading in services are annotated with @Transactional(readOnly = true)
. Now I'm testing a service for working with a directory. The directory entity itself is marked with annotations: @Entity
, @Immutable
, @EntityListeners(PreventAnyUpdate.class)
.
public class PreventAnyUpdate {
@PrePersist
void onPrePersist(Object o) {
throw new RuntimeException("Can't create Entity!");
}
@PreRemove
void onPreRemove(Object o) {
throw new RuntimeException("Can't delete Entity");
}
}
delete()
. Should throw an exception, but does not throw, but deletes everything normally (which it should not do at all). What's wrong?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question