Class QuerydslExecutionStrategy<T,R,F>
java.lang.Object
nl.datasteel.crudcraft.runtime.service.strategy.QuerydslExecutionStrategy<T,R,F>
- All Implemented Interfaces:
QueryExecutionStrategy<T>
Executes queries using a
QuerydslPredicateExecutor
.-
Constructor Summary
ConstructorsConstructorDescriptionQuerydslExecutionStrategy
(org.springframework.data.querydsl.QuerydslPredicateExecutor<T> repository, EntityMapper<T, ?, R, F, ?> mapper, Class<R> responseClass, Class<F> refClass, org.springframework.data.jpa.repository.JpaSpecificationExecutor<T> specRepository) Constructs a new execution strategy using the provided repository. -
Method Summary
Modifier and TypeMethodDescriptionlong
count
(com.querydsl.core.types.Predicate predicate, org.springframework.data.jpa.domain.Specification<T> spec) Counts the number of entities matching the given predicate and specification.boolean
exists
(com.querydsl.core.types.Predicate predicate, org.springframework.data.jpa.domain.Specification<T> spec) Checks if any entity matches the given predicate and specification.findAll
(com.querydsl.core.types.Predicate predicate, org.springframework.data.jpa.domain.Specification<T> spec) Finds all entities matching the given predicate and specification.<P> List
<P> findAll
(com.querydsl.core.types.Predicate predicate, org.springframework.data.jpa.domain.Specification<T> spec, Class<P> projection) Finds all entities matching the given predicate and specification, returning them as the specified projection type.org.springframework.data.domain.Page
<T> findAll
(com.querydsl.core.types.Predicate predicate, org.springframework.data.jpa.domain.Specification<T> spec, org.springframework.data.domain.Pageable pageable) Finds all entities matching the given predicate and specification, returning a paginated result.<P> org.springframework.data.domain.Page
<P> findAll
(com.querydsl.core.types.Predicate predicate, org.springframework.data.jpa.domain.Specification<T> spec, org.springframework.data.domain.Pageable pageable, Class<P> projection) Finds all entities matching the given predicate and specification, returning a paginated result.findOne
(com.querydsl.core.types.Predicate predicate, org.springframework.data.jpa.domain.Specification<T> spec) Finds a single entity matching the given predicate and specification.<P> Optional
<P> findOne
(com.querydsl.core.types.Predicate predicate, org.springframework.data.jpa.domain.Specification<T> spec, Class<P> projection) Finds a single entity matching the given predicate and specification, returning it as the specified projection type.
-
Constructor Details
-
QuerydslExecutionStrategy
public QuerydslExecutionStrategy(org.springframework.data.querydsl.QuerydslPredicateExecutor<T> repository, EntityMapper<T, ?, R, F, ?> mapper, Class<R> responseClass, Class<F> refClass, org.springframework.data.jpa.repository.JpaSpecificationExecutor<T> specRepository) Constructs a new execution strategy using the provided repository.- Parameters:
repository
- the QueryDSL predicate executor to use for query executionmapper
- the mapper for converting entities to DTOsresponseClass
- the response DTO classrefClass
- the reference DTO class
-
-
Method Details
-
findAll
public org.springframework.data.domain.Page<T> findAll(com.querydsl.core.types.Predicate predicate, org.springframework.data.jpa.domain.Specification<T> spec, org.springframework.data.domain.Pageable pageable) Finds all entities matching the given predicate and specification, returning a paginated result.- Specified by:
findAll
in interfaceQueryExecutionStrategy<T>
- Parameters:
predicate
- the QueryDSL predicate to filter resultsspec
- the JPA specification to apply additional filterspageable
- the pagination information- Returns:
- a page of entities matching the criteria
-
findAll
public List<T> findAll(com.querydsl.core.types.Predicate predicate, org.springframework.data.jpa.domain.Specification<T> spec) Finds all entities matching the given predicate and specification.- Specified by:
findAll
in interfaceQueryExecutionStrategy<T>
- Parameters:
predicate
- the QueryDSL predicate to filter resultsspec
- the JPA specification to apply additional filters- Returns:
- a list of entities matching the criteria
-
findAll
public <P> org.springframework.data.domain.Page<P> findAll(com.querydsl.core.types.Predicate predicate, org.springframework.data.jpa.domain.Specification<T> spec, org.springframework.data.domain.Pageable pageable, Class<P> projection) Finds all entities matching the given predicate and specification, returning a paginated result.- Specified by:
findAll
in interfaceQueryExecutionStrategy<T>
- Parameters:
predicate
- the QueryDSL predicate to filter resultsspec
- the JPA specification to apply additional filterspageable
- the pagination informationprojection
- the class type for the projection- Returns:
- a page of entities matching the criteria
-
findAll
public <P> List<P> findAll(com.querydsl.core.types.Predicate predicate, org.springframework.data.jpa.domain.Specification<T> spec, Class<P> projection) Finds all entities matching the given predicate and specification, returning them as the specified projection type.- Specified by:
findAll
in interfaceQueryExecutionStrategy<T>
- Parameters:
predicate
- the QueryDSL predicate to filter resultsspec
- the JPA specification to apply additional filtersprojection
- the class of the projection type- Returns:
- a list of projected entities matching the criteria
-
findOne
public Optional<T> findOne(com.querydsl.core.types.Predicate predicate, org.springframework.data.jpa.domain.Specification<T> spec) Finds a single entity matching the given predicate and specification.- Specified by:
findOne
in interfaceQueryExecutionStrategy<T>
- Parameters:
predicate
- the QueryDSL predicate to filter resultsspec
- the JPA specification to apply additional filters- Returns:
- an Optional containing the entity if found, or empty if not found
-
findOne
public <P> Optional<P> findOne(com.querydsl.core.types.Predicate predicate, org.springframework.data.jpa.domain.Specification<T> spec, Class<P> projection) Finds a single entity matching the given predicate and specification, returning it as the specified projection type.- Specified by:
findOne
in interfaceQueryExecutionStrategy<T>
- Parameters:
predicate
- the QueryDSL predicate to filter resultsspec
- the JPA specification to apply additional filtersprojection
- the class of the projection type- Returns:
- an Optional containing the projected entity, or empty if no match is found
-
exists
public boolean exists(com.querydsl.core.types.Predicate predicate, org.springframework.data.jpa.domain.Specification<T> spec) Checks if any entity matches the given predicate and specification.- Specified by:
exists
in interfaceQueryExecutionStrategy<T>
- Parameters:
predicate
- the QueryDSL predicate to filter resultsspec
- the JPA specification to apply additional filters- Returns:
- true if at least one entity matches the criteria, false otherwise
-
count
public long count(com.querydsl.core.types.Predicate predicate, org.springframework.data.jpa.domain.Specification<T> spec) Counts the number of entities matching the given predicate and specification.- Specified by:
count
in interfaceQueryExecutionStrategy<T>
- Parameters:
predicate
- the QueryDSL predicate to filter resultsspec
- the JPA specification to apply additional filters- Returns:
- the count of entities matching the criteria
-