Boa noite.
Estou com uma problema ao tentar realizar uma consulta SQL no Spring Boot utilizando JPA
Eu preciso passar na URI uma data e ele me trazer as Tasks que estão com o atributo CreatedAt igual ao do parâmetro passado na URI.
Porém para não começar com Data, tentei fazer um SQL utilizando o atributo Name, porém ele me retorna o seguinte erro: Failed to convert value of type ‘java.lang.String’ to required type ‘java.lang.Long’; nested exception is java.lang.NumberFormatException: For input string:
Vou deixar abaixo as partes do meu código
ENTIDADE
Entity
public class Task implements Serializable{
private static final long serialVersionUID = 1L;
Id
GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
NotNull
private String name;
NotNull
private Integer weight;
NotNull
private boolean completed;
NotNull
DateTimeFormat(pattern = "dd-MM-yyyy")
private Date createdAt;
public Task() {
}
public Task(Long id, String name, Integer weight, boolean completed, Date createdAt) {
super();
this.id = id;
this.name = name;
this.weight = weight;
this.completed = completed;
this.createdAt = createdAt;
}
CONTROLLER
Controller
RequestMapping("/task")
public class TaskController {
Autowired
private TaskService taskService;
Autowired
private TaskRepository taskRepository;
GetMapping
public ResponseEntity<List<Task>> findName(@RequestParam String name){
List<Task> list = taskService.findName(name);
return ResponseEntity.ok(list);
}
SERVICE
Service
public class TaskService {
@Autowired
private TaskRepository taskRepository;
public List<Task> findName(String name){
return taskRepository.findName(name);
}
REPOSITORY
Repository
Transactional
public interface TaskRepository extends JpaRepository<Task, Long>{
Query(value = "SELECT * FROM Task WHERE name = ?", nativeQuery = true)
List<Task> findName(String name);
}
Se algum puder me ajudar, por favor
Agradeço muito.




