Description
From how I understand the JPA specs there would be nothing wrong with the following Spring Data JPA annotation:
@EntityGraph(attributePaths = {}) // Purpose: exclude all EAGER relations
The purpose would be to create a query using an entity graph with no attributes added. Perfectly legal in JPA. (and indeed a valid use case)
However, with Spring Data JPA this is not possible as class JpaEntityGraph
uses the following (flawed?) logic to distinguish between dynamic and static named graphs:
public boolean isAdHocEntityGraph() {
return !attributePaths.isEmpty();
}
Therefore, the query result in an exception :
java.lang.IllegalArgumentException: The given JpaEntityGraph [...] is not dynamic
This is wrong. The entity graph is indeed dynamic. It just happens to be an entity graph with no attributes added.
Another way to phrase the problem is that putting this on a query method in a Spring Data repo:
@EntityGraph(attributePaths = {})
should NOT result in an exception, but should result in a query being performed using an JPA entity graph with no attributes added. Alternatively, please provide another way to achieve the goal.
Thanks.