I am working on a project with Spring boot. I have a problem with Spring JPA Data. I want to check if a record already exists in the db using two parameters
@Transactional
@Modifying
@Query("SELECT CASE WHEN COUNT(dfe) > 0 THEN 'true' ELSE 'false' END FROM DeployedFunctionEntity dfe WHERE dfe.function.idFunction = ?1 and dfe.gatewayId = ?2")
boolean existsByFunctionIdAndGatewayId(@Param("idFunction") Integer functionId,
@Param("gatewayId") Integer gatewayId);
boolean exist = deployedFunctionDao.existsByFunctionIdAndGatewayId(functionId, gatewayId);
I always get the following error:
org.springframework.dao.InvalidDataAccessApiUsageException: Modifying queries can only use void or int/Integer as return type!;
The nested exception is
java.lang.IllegalArgumentException: Modifying queries can only use void or int/Integer as return type!
How can I fix it?