Hello Florence Watry, thanks for the feedback and for the reproducer. I went through your code and I think the problem is the type of GraphSemantic you’re using. In your example you’re using the hint jakarta.persistence.fetchgraph which, if you read the javadoc for GraphSemantic#FETCH, is behaving correctly:
Attributes explicitly specified using an AttributeNodes are treated as jakarta.persistence.FetchType.EAGER and fetched via a join or subsequent select. Attributes not explicitly specified are treated as jakarta.persistence.FetchType.LAZY and are not fetched.
You should try using jakarta.persistence.loadgraph (GraphSemantic#LOAD) which allows to specify which attributes to eagerly load while maintaining the configured fetch type for other attributes. Let me know if that helps. |