I have below code to filter the data with given criteria:
public Page<Entity_DTO> findByCriteria(Entity_Criteria criteria, Pageable page) {
final Specification<Entity> specification = createSpecification(criteria);
return Page<Entity_DTO> Entity_DTOPage =
Entity_Repo.findAll(specification, page).map(Entity_DTO_Mapper::toDTO);
}
createSpecification creates a JPA Specification based on the criteria. Now i want to add another filter, but the problem is that filter can't be added to createSpecification because i don't have a repository class for that filter as the filter is stored in a table which is managed by external library. So i can't create an Entity and Repository class for that filter. But i have access to that table using custom sql queries. So i want to know if there's a way to add a custom query(more specifically WHERE) alongside the specification variable created using createSpecification to return the filtered data. Or do i need to do away with the specification and perform filtering solely using queries? Current filters are like health, size etc. and i want to add another filter say status.