Correcting sort object reference in FetchableFluentQueryByExample.sortBy and FetchableFluentQueryByPredicate.sortBy
Closes #2438 Original pull request #2439
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2021 the original author or authors.
|
* Copyright 2021-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -45,6 +45,7 @@ import org.springframework.util.Assert;
|
|||||||
* @author Greg Turnquist
|
* @author Greg Turnquist
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @author Jens Schauder
|
* @author Jens Schauder
|
||||||
|
* @author J.R. Onyschak
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
class FetchableFluentQueryByExample<S, R> extends FluentQuerySupport<S, R> implements FetchableFluentQuery<R> {
|
class FetchableFluentQueryByExample<S, R> extends FluentQuerySupport<S, R> implements FetchableFluentQuery<R> {
|
||||||
@@ -82,8 +83,8 @@ class FetchableFluentQueryByExample<S, R> extends FluentQuerySupport<S, R> imple
|
|||||||
|
|
||||||
Assert.notNull(sort, "Sort must not be null!");
|
Assert.notNull(sort, "Sort must not be null!");
|
||||||
|
|
||||||
return new FetchableFluentQueryByExample<>(example, entityType, resultType, sort.and(sort), properties, finder,
|
return new FetchableFluentQueryByExample<>(example, entityType, resultType, this.sort.and(sort), properties,
|
||||||
countOperation, existsOperation, entityManager, escapeCharacter);
|
finder, countOperation, existsOperation, entityManager, escapeCharacter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2021 the original author or authors.
|
* Copyright 2021-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -46,6 +46,7 @@ import com.querydsl.jpa.impl.AbstractJPAQuery;
|
|||||||
* @author Greg Turnquist
|
* @author Greg Turnquist
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @author Jens Schauder
|
* @author Jens Schauder
|
||||||
|
* @author J.R. Onyschak
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
class FetchableFluentQueryByPredicate<S, R> extends FluentQuerySupport<S, R> implements FetchableFluentQuery<R> {
|
class FetchableFluentQueryByPredicate<S, R> extends FluentQuerySupport<S, R> implements FetchableFluentQuery<R> {
|
||||||
@@ -85,8 +86,8 @@ class FetchableFluentQueryByPredicate<S, R> extends FluentQuerySupport<S, R> imp
|
|||||||
|
|
||||||
Assert.notNull(sort, "Sort must not be null!");
|
Assert.notNull(sort, "Sort must not be null!");
|
||||||
|
|
||||||
return new FetchableFluentQueryByPredicate<>(predicate, entityType, resultType, sort.and(sort), properties, finder,
|
return new FetchableFluentQueryByPredicate<>(predicate, entityType, resultType, this.sort.and(sort), properties,
|
||||||
pagedFinder, countOperation, existsOperation, entityManager);
|
finder, pagedFinder, countOperation, existsOperation, entityManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.springframework.data.jpa.repository.support;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.*;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.data.domain.Example;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.domain.Sort.Order;
|
||||||
|
import org.springframework.data.jpa.repository.support.FetchableFluentQueryByExample;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit tests for {@link FetchableFluentQueryByExample}.
|
||||||
|
*
|
||||||
|
* @author J.R. Onyschak
|
||||||
|
*/
|
||||||
|
class FetchableFluentQueryByExampleUnitTests {
|
||||||
|
|
||||||
|
@Test // GH-2438
|
||||||
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
|
void multipleSortBy() {
|
||||||
|
Sort s1 = Sort.by(Order.by("s1"));
|
||||||
|
Sort s2 = Sort.by(Order.by("s2"));
|
||||||
|
FetchableFluentQueryByExample f = new FetchableFluentQueryByExample(Example.of(""), null, null, null, null, null);
|
||||||
|
f = (FetchableFluentQueryByExample) f.sortBy(s1).sortBy(s2);
|
||||||
|
assertThat(f.sort).isEqualTo(s1.and(s2));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.springframework.data.jpa.repository.support;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.*;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.domain.Sort.Order;
|
||||||
|
import org.springframework.data.jpa.repository.support.FetchableFluentQueryByPredicate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit tests for {@link FetchableFluentQueryByPredicate}.
|
||||||
|
*
|
||||||
|
* @author J.R. Onyschak
|
||||||
|
*/
|
||||||
|
class FetchableFluentQueryByPredicateUnitTests {
|
||||||
|
|
||||||
|
@Test // GH-2438
|
||||||
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
|
void multipleSortBy() {
|
||||||
|
Sort s1 = Sort.by(Order.by("s1"));
|
||||||
|
Sort s2 = Sort.by(Order.by("s2"));
|
||||||
|
FetchableFluentQueryByPredicate f = new FetchableFluentQueryByPredicate(null, null, null, null, null, null, null);
|
||||||
|
f = (FetchableFluentQueryByPredicate) f.sortBy(s1).sortBy(s2);
|
||||||
|
assertThat(f.sort).isEqualTo(s1.and(s2));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user