Class QuerydslExecutionStrategy<T,R,F>

java.lang.Object
nl.datasteel.crudcraft.runtime.service.strategy.QuerydslExecutionStrategy<T,R,F>
All Implemented Interfaces:
QueryExecutionStrategy<T>

public class QuerydslExecutionStrategy<T,R,F> extends Object implements QueryExecutionStrategy<T>
Executes queries using a QuerydslPredicateExecutor.
  • Constructor Summary

    Constructors
    Constructor
    Description
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 execution
      mapper - the mapper for converting entities to DTOs
      responseClass - the response DTO class
      refClass - 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 interface QueryExecutionStrategy<T>
      Parameters:
      predicate - the QueryDSL predicate to filter results
      spec - the JPA specification to apply additional filters
      pageable - 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 interface QueryExecutionStrategy<T>
      Parameters:
      predicate - the QueryDSL predicate to filter results
      spec - 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 interface QueryExecutionStrategy<T>
      Parameters:
      predicate - the QueryDSL predicate to filter results
      spec - the JPA specification to apply additional filters
      pageable - the pagination information
      projection - 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 interface QueryExecutionStrategy<T>
      Parameters:
      predicate - the QueryDSL predicate to filter results
      spec - the JPA specification to apply additional filters
      projection - 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 interface QueryExecutionStrategy<T>
      Parameters:
      predicate - the QueryDSL predicate to filter results
      spec - 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 interface QueryExecutionStrategy<T>
      Parameters:
      predicate - the QueryDSL predicate to filter results
      spec - the JPA specification to apply additional filters
      projection - 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 interface QueryExecutionStrategy<T>
      Parameters:
      predicate - the QueryDSL predicate to filter results
      spec - 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 interface QueryExecutionStrategy<T>
      Parameters:
      predicate - the QueryDSL predicate to filter results
      spec - the JPA specification to apply additional filters
      Returns:
      the count of entities matching the criteria