DATAJPA-790 - Polishing.
JavaDoc, formattgin, license years, author headers. Related tickets: DATAJPA-684 Original pull request: #182.
This commit is contained in:
@@ -137,7 +137,7 @@ public class QueryDslJpaRepository<T, ID extends Serializable> extends SimpleJpa
|
||||
@Override
|
||||
public Page<T> findAll(Predicate predicate, Pageable pageable) {
|
||||
|
||||
JPQLQuery<?> countQuery = createCountQuery(predicate);
|
||||
final JPQLQuery<?> countQuery = createCountQuery(predicate);
|
||||
JPQLQuery<T> query = querydsl.applyPagination(pageable, createQuery(predicate).select(path));
|
||||
|
||||
long total = countQuery.fetchCount();
|
||||
@@ -192,7 +192,7 @@ public class QueryDslJpaRepository<T, ID extends Serializable> extends SimpleJpa
|
||||
/**
|
||||
* Creates a new {@link JPQLQuery} count query for the given {@link Predicate}.
|
||||
*
|
||||
* @param predicate
|
||||
* @param predicate, can be {@literal null}.
|
||||
* @return the Querydsl count {@link JPQLQuery}.
|
||||
*/
|
||||
protected JPQLQuery<?> createCountQuery(Predicate predicate) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
* Copyright 2014-2016 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.
|
||||
@@ -44,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
*
|
||||
* @author Thomas Darimont
|
||||
* @author Oliver Gierke
|
||||
* @author Jocelyn Ntakpe
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:config/namespace-autoconfig-context.xml")
|
||||
@@ -137,12 +138,14 @@ public class EntityGraphRepositoryMethodsIntegrationTests {
|
||||
*/
|
||||
@Test
|
||||
public void shouldRespectConfiguredJpaEntityGraphWithPaginationAndQueryDslPredicates() {
|
||||
|
||||
Assume.assumeTrue(currentEntityManagerIsAJpa21EntityManager(em));
|
||||
|
||||
Page<User> page = repository.findAll(QUser.user.firstname.isNotNull(), new PageRequest(0, 100));
|
||||
List<User> result = page.getContent();
|
||||
|
||||
assertThat(result.size(), is(2));
|
||||
assertThat(Persistence.getPersistenceUtil().isLoaded(result.get(0).getRoles()), is(true));
|
||||
assertThat(result.get(0), is(tom));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
* Copyright 2014-2016 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.
|
||||
@@ -17,7 +17,6 @@ package org.springframework.data.jpa.repository.sample;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.querydsl.core.types.Predicate;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.sample.User;
|
||||
@@ -26,6 +25,8 @@ import org.springframework.data.jpa.repository.EntityGraph.EntityGraphType;
|
||||
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
import com.querydsl.core.types.Predicate;
|
||||
|
||||
/**
|
||||
* Custom repository interface that customizes the fetching behavior of querys of well known repository interface
|
||||
* methods via {@link EntityGraph} annotation.
|
||||
@@ -33,7 +34,8 @@ import org.springframework.data.repository.CrudRepository;
|
||||
* @author Thomas Darimont
|
||||
* @author Jocelyn Ntakpe
|
||||
*/
|
||||
public interface RepositoryMethodsWithEntityGraphConfigRepository extends CrudRepository<User, Integer>, QueryDslPredicateExecutor<User> {
|
||||
public interface RepositoryMethodsWithEntityGraphConfigRepository
|
||||
extends CrudRepository<User, Integer>, QueryDslPredicateExecutor<User> {
|
||||
|
||||
/**
|
||||
* Should find all users.
|
||||
@@ -52,7 +54,7 @@ public interface RepositoryMethodsWithEntityGraphConfigRepository extends CrudRe
|
||||
*/
|
||||
@EntityGraph
|
||||
User getOneWithDefinedEntityGraphById(Integer id);
|
||||
|
||||
|
||||
/**
|
||||
* @see DATAJPA-696
|
||||
*/
|
||||
@@ -62,6 +64,6 @@ public interface RepositoryMethodsWithEntityGraphConfigRepository extends CrudRe
|
||||
/**
|
||||
* @see DATAJPA-790
|
||||
*/
|
||||
@EntityGraph(type = EntityGraphType.FETCH, value = "User.detail")
|
||||
@EntityGraph("User.detail")
|
||||
Page<User> findAll(Predicate predicate, Pageable pageable);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user