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:
@@ -169,17 +169,22 @@ public class Jpa21Utils {
|
|||||||
} else if (parent != null && !exists(attributeName, parent.getAttributeNodes())) {
|
} else if (parent != null && !exists(attributeName, parent.getAttributeNodes())) {
|
||||||
parent.addAttributeNodes(attributeName);
|
parent.addAttributeNodes(attributeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AttributeNode<?> node = findAttributeNode(attributeName, root, parent);
|
AttributeNode<?> node = findAttributeNode(attributeName, root, parent);
|
||||||
|
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
|
|
||||||
Subgraph<?> subgraph = getSubgraph(node);
|
Subgraph<?> subgraph = getSubgraph(node);
|
||||||
|
|
||||||
if (subgraph == null) {
|
if (subgraph == null) {
|
||||||
subgraph = parent != null ? parent.addSubgraph(attributeName) : root.addSubgraph(attributeName);
|
subgraph = parent != null ? parent.addSubgraph(attributeName) : root.addSubgraph(attributeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
createGraph(pathComponents, offset + 1, root, subgraph);
|
createGraph(pathComponents, offset + 1, root, subgraph);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +217,7 @@ public class Jpa21Utils {
|
|||||||
* @return {@literal null} if not found.
|
* @return {@literal null} if not found.
|
||||||
*/
|
*/
|
||||||
private static AttributeNode<?> findAttributeNode(String attributeNodeName, EntityGraph<?> entityGraph,
|
private static AttributeNode<?> findAttributeNode(String attributeNodeName, EntityGraph<?> entityGraph,
|
||||||
Subgraph parent) {
|
Subgraph<?> parent) {
|
||||||
return findAttributeNode(attributeNodeName,
|
return findAttributeNode(attributeNodeName,
|
||||||
parent != null ? parent.getAttributeNodes() : entityGraph.getAttributeNodes());
|
parent != null ? parent.getAttributeNodes() : entityGraph.getAttributeNodes());
|
||||||
}
|
}
|
||||||
@@ -247,5 +252,4 @@ public class Jpa21Utils {
|
|||||||
private static Subgraph<?> getSubgraph(AttributeNode<?> node) {
|
private static Subgraph<?> getSubgraph(AttributeNode<?> node) {
|
||||||
return node.getSubgraphs().isEmpty() ? null : node.getSubgraphs().values().iterator().next();
|
return node.getSubgraphs().isEmpty() ? null : node.getSubgraphs().values().iterator().next();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,9 +134,6 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
|
|||||||
em.flush();
|
em.flush();
|
||||||
em.clear();
|
em.clear();
|
||||||
|
|
||||||
em.flush();
|
|
||||||
em.clear();
|
|
||||||
|
|
||||||
User user = repository.getOneWithAttributeNamesById(tom.getId());
|
User user = repository.getOneWithAttributeNamesById(tom.getId());
|
||||||
|
|
||||||
assertThat(user, is(notNullValue()));
|
assertThat(user, is(notNullValue()));
|
||||||
@@ -217,14 +214,16 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
|
|||||||
User user = repository.findOneWithDeepGraphById(tom.getId());
|
User user = repository.findOneWithDeepGraphById(tom.getId());
|
||||||
|
|
||||||
assertThat(user, is(notNullValue()));
|
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));
|
Persistence.getPersistenceUtil().isLoaded(user, "colleagues"), is(true));
|
||||||
|
|
||||||
for (User colleague : user.getColleagues()) {
|
for (User colleague : user.getColleagues()) {
|
||||||
|
|
||||||
assertThat(Persistence.getPersistenceUtil().isLoaded(colleague, "colleagues"), is(true));
|
assertThat(Persistence.getPersistenceUtil().isLoaded(colleague, "colleagues"), is(true));
|
||||||
assertThat(Persistence.getPersistenceUtil().isLoaded(colleague, "roles"), is(true));
|
assertThat(Persistence.getPersistenceUtil().isLoaded(colleague, "roles"), is(true));
|
||||||
|
|
||||||
for (User colleagueOfColleague : colleague.getColleagues()) {
|
for (User colleagueOfColleague : colleague.getColleagues()) {
|
||||||
|
|
||||||
assertThat(Persistence.getPersistenceUtil().isLoaded(colleagueOfColleague, "roles"), is(true));
|
assertThat(Persistence.getPersistenceUtil().isLoaded(colleagueOfColleague, "roles"), is(true));
|
||||||
assertThat(Persistence.getPersistenceUtil().isLoaded(colleagueOfColleague, "colleagues"), is(false));
|
assertThat(Persistence.getPersistenceUtil().isLoaded(colleagueOfColleague, "colleagues"), is(false));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,4 @@ import org.springframework.test.context.ContextConfiguration;
|
|||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
*/
|
*/
|
||||||
@ContextConfiguration("classpath:eclipselink.xml")
|
@ContextConfiguration("classpath:eclipselink.xml")
|
||||||
public class EclipseLinkJpa21UtilsTests extends Jpa21UtilsTests {
|
public class EclipseLinkJpa21UtilsTests extends Jpa21UtilsTests {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user