Parameter value [1] did not match expected type [java.lang.Boolean]
hql, java, spring
Solution
You seem to have mapped `Workflow.active` attribute as a `Boolean`. So you repository should be like:
@Repository
public interface WorkflowRepository extends JpaRepository<Workflow, Boolean> {
List<Workflow> findByActive(@Param("active") Boolean active);
}
And the call `workflowRepository.findByActive(true)` should behave how you want it to.
The fact is that HQL sometimes make a type difference between database and Java mapping, because typing isn't the same in these environments. So check your `Entity`'s `active` type to make the appropriate `Repository`.
Problem
I'm getting the error `Exception in thread "main" org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [1] did not match expected type [java.lang.Boolean]; nested exception is java.lang.IllegalArgumentException: Parameter value [1] did not match expected type [java.lang.Boolean]`. I'm confused by this because it's coming from the service method shown below that is commented out. When I comment it out, the error is avoided. The `active` column is a `TINYINT(1)` that's either `1` or `0`. Entity: ``` @Entity @NamedQueries({ @NamedQuery(name="Workflow.findByUUID", query="SELECT w FROM Workflow w WHERE w.uuid = :uuid"), @NamedQuery(name="Workflow.findByActive", query="SELECT w FROM Workflow w WHERE w.active = :active ORDER BY id ASC") }) ``` My Repository: ``` @Repository public interface WorkflowRepository extends JpaRepository<Workflow, Integer> { List<Workflow> findByActive(@Param("active") Integer active); } ``` My Service: ``` @Service public class WorkflowService { @Autowired WorkflowRepository workflowRepository; /** * Get active workflows */ @Transactional(readOnly = true) public List<Workflow> findActive() { //return workflowRepository.findByActive(1); return null; } ``` When I uncomment