DATAJPA-1075 - Polishing.

Formatting and generic types over raw types in Jpa21Utils. Removed superfluous EntityManager.flush() and ….clear() from EntityGraphRepositoryMethodsIntegrationTests. Formatting, spelling.

Original pull request: #192.
This commit is contained in:
Oliver Gierke
2017-04-18 10:25:42 +02:00
parent d98ce700e7
commit b290ee6fb9
3 changed files with 11 additions and 10 deletions

View File

@@ -168,17 +168,22 @@ public class Jpa21Utils {
} else if (parent != null && !exists(attributeName, parent.getAttributeNodes())) {
parent.addAttributeNodes(attributeName);
}
return;
}
AttributeNode<?> node = findAttributeNode(attributeName, root, parent);
if (node != null) {
Subgraph<?> subgraph = getSubgraph(node);
if (subgraph == null) {
subgraph = parent != null ? parent.addSubgraph(attributeName) : root.addSubgraph(attributeName);
}
createGraph(pathComponents, offset + 1, root, subgraph);
return;
}
@@ -211,7 +216,7 @@ public class Jpa21Utils {
* @return {@literal null} if not found.
*/
private static AttributeNode<?> findAttributeNode(String attributeNodeName, EntityGraph<?> entityGraph,
Subgraph parent) {
Subgraph<?> parent) {
return findAttributeNode(attributeNodeName,
parent != null ? parent.getAttributeNodes() : entityGraph.getAttributeNodes());
}
@@ -246,5 +251,4 @@ public class Jpa21Utils {
private static Subgraph<?> getSubgraph(AttributeNode<?> node) {
return node.getSubgraphs().isEmpty() ? null : node.getSubgraphs().values().iterator().next();
}
}

View File

@@ -146,9 +146,6 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
em.flush();
em.clear();
em.flush();
em.clear();
User user = repository.getOneWithAttributeNamesById(tom.getId());
assertThat(user, is(notNullValue()));
@@ -232,14 +229,16 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
User user = repository.findOneWithDeepGraphById(tom.getId());
assertThat(user, is(notNullValue()));
assertThat("colleagues on root should have been fetched by dynamic subgraph declaration",
assertThat("Colleagues on root should have been fetched by dynamic subgraph declaration",
Persistence.getPersistenceUtil().isLoaded(user, "colleagues"), is(true));
for (User colleague : user.getColleagues()) {
assertThat(Persistence.getPersistenceUtil().isLoaded(colleague, "colleagues"), is(true));
assertThat(Persistence.getPersistenceUtil().isLoaded(colleague, "roles"), is(true));
for (User colleagueOfColleague : colleague.getColleagues()) {
assertThat(Persistence.getPersistenceUtil().isLoaded(colleagueOfColleague, "roles"), is(true));
assertThat(Persistence.getPersistenceUtil().isLoaded(colleagueOfColleague, "colleagues"), is(false));
}

View File

@@ -21,6 +21,4 @@ import org.springframework.test.context.ContextConfiguration;
* @author Christoph Strobl
*/
@ContextConfiguration("classpath:eclipselink.xml")
public class EclipseLinkJpa21UtilsTests extends Jpa21UtilsTests {
}
public class EclipseLinkJpa21UtilsTests extends Jpa21UtilsTests {}