DATACMNS-33 - Adapted API changes for Repository.count().
Also changed return types for count() methods on JpaSpecificationExecutore and QueryDslPredicateExecutor.
This commit is contained in:
@@ -23,7 +23,6 @@ import javax.persistence.EntityManager;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -96,7 +95,7 @@ public interface JpaRepository<T, ID extends Serializable> extends
|
||||
*
|
||||
* @see org.springframework.data.repository.Repository#count()
|
||||
*/
|
||||
Long count();
|
||||
long count();
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -78,5 +78,5 @@ public interface JpaSpecificationExecutor<T> {
|
||||
* @param spec the {@link Specification} to count instances for
|
||||
* @return the number of instances
|
||||
*/
|
||||
Long count(Specification<T> spec);
|
||||
long count(Specification<T> spec);
|
||||
}
|
||||
|
||||
@@ -77,5 +77,5 @@ public interface QueryDslPredicateExecutor<T> {
|
||||
* @param predicate the {@link Predicate} to count instances for
|
||||
* @return the number of instances
|
||||
*/
|
||||
Long count(Predicate predicate);
|
||||
long count(Predicate predicate);
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ public class QueryDslJpaRepository<T, ID extends Serializable> extends
|
||||
* @see org.springframework.data.jpa.repository.querydsl.
|
||||
* QueryDslSpecificationExecutor#count(com.mysema.query.types.Predicate)
|
||||
*/
|
||||
public Long count(Predicate predicate) {
|
||||
public long count(Predicate predicate) {
|
||||
|
||||
return createQuery(predicate).count();
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ public class SimpleJpaRepository<T, ID extends Serializable> implements
|
||||
*
|
||||
* @see org.springframework.data.repository.Repository#count()
|
||||
*/
|
||||
public Long count() {
|
||||
public long count() {
|
||||
|
||||
return em.createQuery(getCountQueryString(), Long.class)
|
||||
.getSingleResult();
|
||||
@@ -318,7 +318,7 @@ public class SimpleJpaRepository<T, ID extends Serializable> implements
|
||||
* org.springframework.data.jpa.repository.JpaSpecificationExecutor#count
|
||||
* (org.springframework.data.jpa.domain.Specification)
|
||||
*/
|
||||
public Long count(Specification<T> spec) {
|
||||
public long count(Specification<T> spec) {
|
||||
|
||||
return getCountQuery(spec).getSingleResult();
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ public class UserRepositoryTests {
|
||||
private void assertDeleteCallDoesNotDeleteAnything(List<User> collection) {
|
||||
|
||||
flushTestUsers();
|
||||
Long count = repository.count();
|
||||
long count = repository.count();
|
||||
|
||||
repository.delete(collection);
|
||||
assertEquals(count, repository.count());
|
||||
@@ -267,9 +267,9 @@ public class UserRepositoryTests {
|
||||
flushTestUsers();
|
||||
repository.renameAllUsersTo("newLastname");
|
||||
|
||||
Integer expected = repository.count().intValue();
|
||||
assertThat(repository.findByLastname("newLastname").size(),
|
||||
is(expected));
|
||||
long expected = repository.count();
|
||||
assertThat(repository.findByLastname("newLastname").size(), is(Long
|
||||
.valueOf(expected).intValue()));
|
||||
}
|
||||
|
||||
|
||||
@@ -349,7 +349,7 @@ public class UserRepositoryTests {
|
||||
|
||||
repository.deleteAll();
|
||||
|
||||
assertEquals((Long) 0L, repository.count());
|
||||
assertEquals(0L, repository.count());
|
||||
}
|
||||
|
||||
|
||||
@@ -415,13 +415,13 @@ public class UserRepositoryTests {
|
||||
@Test
|
||||
public void testCountsCorrectly() {
|
||||
|
||||
Long count = repository.count();
|
||||
long count = repository.count();
|
||||
|
||||
User user = new User();
|
||||
user.setEmailAddress("gierke@synyx.de");
|
||||
repository.save(user);
|
||||
|
||||
assertTrue(repository.count().equals(count + 1));
|
||||
assertTrue(repository.count() == count + 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user