Lift restriction on empty JpaEntityGraph attributes.
This commit removes a check preventing EntityGraphs from being created for JpaEntityGraphs without attributes. Original pull request: #3684 Closes #3682
This commit is contained in:
committed by
Mark Paluch
parent
f8b74eda5b
commit
264ea10517
@@ -129,7 +129,6 @@ public class Jpa21Utils {
|
||||
Assert.notNull(em, "EntityManager must not be null");
|
||||
Assert.notNull(jpaEntityGraph, "JpaEntityGraph must not be null");
|
||||
Assert.notNull(entityType, "Entity type must not be null");
|
||||
Assert.isTrue(jpaEntityGraph.isAdHocEntityGraph(), "The given " + jpaEntityGraph + " is not dynamic");
|
||||
|
||||
EntityGraph<?> entityGraph = em.createEntityGraph(entityType);
|
||||
configureFetchGraphFrom(jpaEntityGraph, entityGraph);
|
||||
|
||||
@@ -50,6 +50,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* @author Mark Paluch
|
||||
* @author Jens Schauder
|
||||
* @author Krzysztof Krason
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration("classpath:application-context.xml")
|
||||
@@ -166,6 +167,15 @@ class Jpa21UtilsTests {
|
||||
em.createEntityGraph(User.class)));
|
||||
}
|
||||
|
||||
@Test // GH-3682
|
||||
void allowsEmptyGraph() {
|
||||
|
||||
EntityGraph<User> graph = em.createEntityGraph(User.class);
|
||||
Jpa21Utils.configureFetchGraphFrom(new JpaEntityGraph("User.NoNamedEntityGraphAvailable", EntityGraphType.FETCH, new String[0]), graph);
|
||||
|
||||
Assertions.assertThat(graph.getAttributeNodes()).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup the {@link AttributeNode} with given {@literal nodeName} in the root of the given {@literal graph}.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user