DATAJPA-1404 - Polishing.

Simplify if-empty comparison. Fix ticket references.

Original pull request: #304.
This commit is contained in:
Mark Paluch
2019-02-28 10:21:01 +01:00
parent db7ab8a56a
commit d58af47322
2 changed files with 8 additions and 7 deletions

View File

@@ -614,7 +614,7 @@ public abstract class QueryUtils {
* @param isPluralAttribute is the attribute of Collection type?
* @param isLeafProperty is this the final property navigated by a {@link PropertyPath}?
* @param isForSelection is the property navigated for the selection part of the query?
* @return wether an outer join is to be used for integrating this attribute in a query.
* @return whether an outer join is to be used for integrating this attribute in a query.
*/
private static boolean requiresOuterJoin(@Nullable Bindable<?> propertyPathModel, boolean isPluralAttribute,
boolean isLeafProperty, boolean isForSelection) {
@@ -637,7 +637,7 @@ public abstract class QueryUtils {
// outer join to avoid https://hibernate.atlassian.net/browse/HHH-12712 and
// https://github.com/eclipse-ee4j/jpa-api/issues/170
boolean isInverseOptionalOneToOne = PersistentAttributeType.ONE_TO_ONE == attribute.getPersistentAttributeType()
&& !getAnnotationProperty(attribute, "mappedBy", "").isEmpty();
&& StringUtils.hasText(getAnnotationProperty(attribute, "mappedBy", ""));
// if this path is part of the select list we need to generate an explicit outer join in order to prevent Hibernate
// to use an inner join instead.
@@ -650,6 +650,7 @@ public abstract class QueryUtils {
}
private static <T> T getAnnotationProperty(Attribute<?, ?> attribute, String propertyName, T defaultValue) {
Class<? extends Annotation> associationAnnotation = ASSOCIATION_TYPES.get(attribute.getPersistentAttributeType());
if (associationAnnotation == null) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2017 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Integration tests for {@link QueryUtils}.
*
*
* @author Oliver Gierke
* @author Sébastien Péralta
*/
@@ -95,7 +95,7 @@ public class QueryUtilsIntegrationTests {
assertThat(getNonInnerJoins(root)).hasSize(1);
}
@Test // DATAJPA-1238
@Test // DATAJPA-1404
public void createsJoinForOptionalOneToOneInReverseDirection() {
doInMerchantContext(emf -> {
@@ -110,7 +110,7 @@ public class QueryUtilsIntegrationTests {
});
}
@Test // DATAJPA-1238
@Test // DATAJPA-1404
public void createsNoJoinForOptionalOneToOneInNormalDirection() {
doInMerchantContext(emf -> {
@@ -288,7 +288,7 @@ public class QueryUtilsIntegrationTests {
/**
* A {@link PersistenceProviderResolver} that returns only a Hibernate {@link PersistenceProvider} and ignores others.
*
*
* @author Thomas Darimont
* @author Oliver Gierke
*/