Hi,
I encounter some problem when I try to use org.springframework.data.jpa.repository.EntityGraph to improve performance to fetch my relations.
To do it I’m using the annotation on my repository methods:
@EntityGraph(attributePaths = {"relation"})
I noticed that every time I fetch a relation this way, my parent entities become dirty.
It’s actually problematic in my case since I have a PostCommitUpdateEventListener who catch this as an update and start some unintended logic.
When I watch the PostUpdateEvent’s state and oldState the difference is that every relations are all a LazyPropertyInitializer in the oldState while they are filled in the state with PersistentSet.
It looks like a classic use case and I feel like I’m missing something obvious.
For context I’m using:
hibernate-entitymanager 5.5.8.Final
hibernate-enhance-maven-plugin with enableLazyInitialization to true 5.5.8.Final
spring-boot-starter-parent 2.7.18