What steps will reproduce the problem?
Steps to reproduce the behavior:
I have an Entity with a Listener:
@Entity
@EntityListeners(MyEntityUpdateListener.class)
public class MyEntity {
...
and the Listener needs to modify the database, so it needs a Repository or the entityManager:
public class MyEntityUpdateListener {
private final EntityManager entityManager;
public MyEntityUpdateListener(EntityManager _em) {
...
When starting this, I get
***************************
APPLICATION FAILED TO START
***************************
Description:
The dependencies of some of the beans in the application context form a cycle:
...
↓
myRepository defined in ....MyRepository defined in @EnableJpaRepositories declared on MyApplication
↓
(inner bean)#55e91e61
┌─────┐
| entityManagerFactory defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]
↑ ↓
| ....MyEntityUpdateListener
↑ ↓
| org.springframework.orm.jpa.SharedEntityManagerCreator#0
└─────┘
What is the expected output?
This works fine with standard Spring Boot.
What happens instead?
Should also work with spring-data-jpa-entity-graph
Environment:
Spring Data JPA version (not the Spring Boot one): 2.3.4.RELEASE
What steps will reproduce the problem? Steps to reproduce the behavior: I have an Entity with a Listener:
and the Listener needs to modify the database, so it needs a Repository or the entityManager:
When starting this, I get
What is the expected output?
This works fine with standard Spring Boot.
What happens instead?
Should also work with spring-data-jpa-entity-graph
Environment:
Things I have tried (none have worked):
@Autowired
- variable will be null@PostUpdate
annotation in the Entity class - same error