Stack Overflow Asked by jbuddy on February 8, 2021
I have an entity A
for which I’d like to register a javax.persistence.EntityListeners
only while running some integration tests.
I tried the following, but didn’t work:
source package
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
@Entity
@EntityListeners(AListener.class)
class A {
// ...
}
interface AListener {
}
tests package
import javax.persistence.PostPersist;
import org.springframework.stereotype.Component;
@Component
class AListenerImpl implements AListener {
@PostPersist
public void doSomethingOnA(A object) {
System.out.println("A object saved: " + object); // <-- never gets called when running the tests
}
}
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP