Skip to content

Commit

Permalink
Repository pageable methods rename refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
talhadilber committed Mar 1, 2024
1 parent d05d0e1 commit a58029f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>io.github.tdilber</groupId>
<artifactId>spring-jpa-dynamic-query</artifactId>
<version>0.3.2</version>
<version>0.3.0</version>
<packaging>jar</packaging>
<name>Spring Jpa Dynamic Query</name>
<description>Spring Jpa Dynamic Query (JDQ) Project</description>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/beyt/jdq/query/DynamicSpecification.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected Predicate addPredicate(Path<?> root, CriteriaBuilder builder, Criteria
criteria.setValues(deserialize(root.get(criteria.getKey()).getJavaType(), criteria.getValues()));
} catch (Exception e) {
throw new DynamicQueryNoAvailableEnumException("There is a "
+ root.get(criteria.getKey()).getJavaType().getSimpleName() + " Enum Problem in Criteria Key: "
+ root.get(criteria.getKey()).getJavaType().getSimpleName() + " Problem in Criteria Key: "
+ criteria.getKey(), e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ public interface DynamicSpecificationRepository<T, ID> extends JpaRepository<T,

List<T> findAll(DynamicQuery dynamicQuery);

Page<T> findAllPage(DynamicQuery dynamicQuery);
Page<T> findAllAsPage(DynamicQuery dynamicQuery);

List<Tuple> findAllTuple(DynamicQuery dynamicQuery);
List<Tuple> findAllAsTuple(DynamicQuery dynamicQuery);

Page<Tuple> findAllPageTuple(DynamicQuery dynamicQuery);
Page<Tuple> findAllAsTuplePage(DynamicQuery dynamicQuery);

<ResultType> List<ResultType> findAll(DynamicQuery dynamicQuery, Class<ResultType> resultTypeClass);

<ResultType> Page<ResultType> findAllPage(DynamicQuery dynamicQuery, Class<ResultType> resultTypeClass);
<ResultType> Page<ResultType> findAllAsPage(DynamicQuery dynamicQuery, Class<ResultType> resultTypeClass);

QueryBuilder<T, ID> queryBuilder();

Page<T> findAll(List<Criteria> criteriaList, Pageable pageable);

long count(List<Criteria> criteriaList);

void fetchPartially(ListConsumer<T> processor, int pageSize);
void consumePartially(ListConsumer<T> processor, int pageSize);

void fetchPartially(Specification<T> specification, ListConsumer<T> processor, int pageSize);
void consumePartially(Specification<T> specification, ListConsumer<T> processor, int pageSize);

void fetchPartially(List<Criteria> criteriaList, ListConsumer<T> processor, int pageSize);
void consumePartially(List<Criteria> criteriaList, ListConsumer<T> processor, int pageSize);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ public List<T> findAll(DynamicQuery dynamicQuery) {
}

@Override
public Page<T> findAllPage(DynamicQuery dynamicQuery) {
public Page<T> findAllAsPage(DynamicQuery dynamicQuery) {
return DynamicQueryManager.getEntityListBySelectableFilterAsPage(this, dynamicQuery);
}

@Override
public List<Tuple> findAllTuple(DynamicQuery dynamicQuery) {
public List<Tuple> findAllAsTuple(DynamicQuery dynamicQuery) {
return DynamicQueryManager.getEntityListBySelectableFilterWithTupleAsList(this, dynamicQuery);
}

@Override
public Page<Tuple> findAllPageTuple(DynamicQuery dynamicQuery) {
public Page<Tuple> findAllAsTuplePage(DynamicQuery dynamicQuery) {
return DynamicQueryManager.getEntityListBySelectableFilterWithTupleAsPage(this, dynamicQuery);
}

Expand All @@ -63,7 +63,7 @@ public <ResultType> List<ResultType> findAll(DynamicQuery dynamicQuery, Class<Re
}

@Override
public <ResultType> Page<ResultType> findAllPage(DynamicQuery dynamicQuery, Class<ResultType> resultTypeClass) {
public <ResultType> Page<ResultType> findAllAsPage(DynamicQuery dynamicQuery, Class<ResultType> resultTypeClass) {
return DynamicQueryManager.getEntityListBySelectableFilterWithReturnTypeAsPage(this, dynamicQuery, resultTypeClass);
}

Expand Down Expand Up @@ -91,12 +91,12 @@ public long count(List<Criteria> criteriaList) {
}

@Override
public void fetchPartially(ListConsumer<T> processor, int pageSize) {
fetchPartially((Specification<T>) null, processor, pageSize);
public void consumePartially(ListConsumer<T> processor, int pageSize) {
consumePartially((Specification<T>) null, processor, pageSize);
}

@Override
public void fetchPartially(Specification<T> specification, ListConsumer<T> processor, int pageSize) {
public void consumePartially(Specification<T> specification, ListConsumer<T> processor, int pageSize) {
Page<T> page = this.findAll((Specification<T>) null, PageRequest.of(0, pageSize));
processor.accept(page.getContent());
long totalElements = page.getTotalElements();
Expand All @@ -107,7 +107,7 @@ public void fetchPartially(Specification<T> specification, ListConsumer<T> proce
}

@Override
public void fetchPartially(List<Criteria> criteriaList, ListConsumer<T> processor, int pageSize) {
public void consumePartially(List<Criteria> criteriaList, ListConsumer<T> processor, int pageSize) {
long totalElements = DynamicQueryManager.count(this, criteriaList);

for (int i = 0; (long) i * pageSize < totalElements; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ default List<T> findAll(DynamicQuery dynamicQuery) {
return DynamicQueryManager.getEntityListBySelectableFilterAsList(this, dynamicQuery);
}

default Page<T> findAllPage(DynamicQuery dynamicQuery) {
default Page<T> findAllAsPage(DynamicQuery dynamicQuery) {
return DynamicQueryManager.getEntityListBySelectableFilterAsPage(this, dynamicQuery);
}

default List<Tuple> findAllTuple(DynamicQuery dynamicQuery) {
default List<Tuple> findAllAsTuple(DynamicQuery dynamicQuery) {
return DynamicQueryManager.getEntityListBySelectableFilterWithTupleAsList(this, dynamicQuery);
}

default Page<Tuple> findAllPageTuple(DynamicQuery dynamicQuery) {
default Page<Tuple> findAllAsTuplePage(DynamicQuery dynamicQuery) {
return DynamicQueryManager.getEntityListBySelectableFilterWithTupleAsPage(this, dynamicQuery);
}

default <ResultType> List<ResultType> findAll(DynamicQuery dynamicQuery, Class<ResultType> resultTypeClass) {
return DynamicQueryManager.getEntityListBySelectableFilterWithReturnTypeAsList(this, dynamicQuery, resultTypeClass);
}

default <ResultType> Page<ResultType> findAllPage(DynamicQuery dynamicQuery, Class<ResultType> resultTypeClass) {
default <ResultType> Page<ResultType> findAllAsPage(DynamicQuery dynamicQuery, Class<ResultType> resultTypeClass) {
return DynamicQueryManager.getEntityListBySelectableFilterWithReturnTypeAsPage(this, dynamicQuery, resultTypeClass);
}

Expand All @@ -53,19 +53,19 @@ default Page<T> findAll(List<Criteria> criteriaList, Pageable pageable) {
return DynamicQueryManager.findAll(this, criteriaList, pageable);
}

static <T> Specification<T> getSpecificationWithCriteria(List<Criteria> criteriaList) {
static <T> Specification<T> createSpecification(List<Criteria> criteriaList) {
return DynamicQueryManager.getSpecification(criteriaList);
}

default long count(List<Criteria> criteriaList) {
return DynamicQueryManager.count(this, criteriaList);
}

default void fetchPartially(ListConsumer<T> processor, int pageSize) {
fetchPartially((Specification<T>) null, processor, pageSize);
default void consumePartially(ListConsumer<T> processor, int pageSize) {
consumePartially((Specification<T>) null, processor, pageSize);
}

default void fetchPartially(Specification<T> specification, ListConsumer<T> processor, int pageSize) {
default void consumePartially(Specification<T> specification, ListConsumer<T> processor, int pageSize) {
Page<T> page = this.findAll((Specification<T>) null, PageRequest.of(0, pageSize));
processor.accept(page.getContent());
long totalElements = page.getTotalElements();
Expand All @@ -75,7 +75,7 @@ default void fetchPartially(Specification<T> specification, ListConsumer<T> proc
}
}

default void fetchPartially(List<Criteria> criteriaList, ListConsumer<T> processor, int pageSize) {
default void consumePartially(List<Criteria> criteriaList, ListConsumer<T> processor, int pageSize) {
long totalElements = DynamicQueryManager.count(this, criteriaList);

for (int i = 0; (long) i * pageSize < totalElements; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ResponseEntity<List<Customer>> getCustomerWithCriteria(CriteriaList crite

@GetMapping("/user/as-page")
public ResponseEntity<Page<User>> getUserWithSearchFilterAsPage(DynamicQuery dynamicQuery) {
Page<User> userList = userRepository.findAllPage(dynamicQuery);
Page<User> userList = userRepository.findAllAsPage(dynamicQuery);
return ResponseEntity.ok().body(userList);
}

Expand All @@ -51,7 +51,7 @@ public ResponseEntity<List<User>> getUserWithSearchFilterAsList(DynamicQuery dyn

@GetMapping("/customer/as-page")
public ResponseEntity<Page<Customer>> getCustomerWithSearchFilterAsPage(DynamicQuery dynamicQuery) {
Page<Customer> customerList = customerRepository.findAllPage(dynamicQuery);
Page<Customer> customerList = customerRepository.findAllAsPage(dynamicQuery);
return ResponseEntity.ok().body(customerList);
}

Expand Down

0 comments on commit a58029f

Please sign in to comment.