具有该位置的参数[5]不存在;

Sta*_*tan 11 java mysql spring

我试图通过查询在我的数据库中请求一些数据,但我得到的只是这个例外:

HTTP Status 500 - Request processing failed; nested exception is
org.springframework.dao.InvalidDataAccessApiUsageException: Parameter with that position [5] did
not exist; nested exception is java.lang.IllegalArgumentException: Parameter with that position [5]
did not exist
Run Code Online (Sandbox Code Playgroud)

好吧,这是我的MappingController

@RequestMapping(value="/vacChange", method = RequestMethod.POST)
public String changedVac(@RequestParam(value = "id", required = true) Integer id,
                         @RequestParam(value = "ort", required = true) String ort,
                         @RequestParam(value = "bereich", required = true) String bereich,
                         @RequestParam(value = "beschreibung", required = true) String beschreibung){
vacService.changeVacancyByID(id,gehalt,ort,bereich,beschreibung);


    return "vacAdmin";
}
Run Code Online (Sandbox Code Playgroud)

我想我不需要写下ServiceClass,但下面是ServiceClassImplementation

public void changeVacancyByID(Integer id, String gehalt,String ort,String bereich,String beschreibung){
        System.out.println("Edit method called");
        VacancyEntity vacEntity = vacancyRepository.findOneById(id);
        vacancyRepository.updateAttributes(id,gehalt,ort,bereich,beschreibung);

}
Run Code Online (Sandbox Code Playgroud)

最后但同样重要的是这是我的存储库:

@Transactional
@Query (value = "UPDATE vacancy SET salary=?1, location=?2,functionality=?3, description=?4 WHERE id = ?0  ", nativeQuery = true)
VacancyEntity updateAttributes(Integer id, String gehalt, String ort, String bereich, String beschreibung);
Run Code Online (Sandbox Code Playgroud)

Pre*_*ric 15

基于位置的参数从1开始,尝试使用此方法

@Query (value = "UPDATE vacancy SET salary=?1, location=?2,functionality=?3, description=?4 WHERE id = ?5  ", nativeQuery = true)
VacancyEntity updateAttributes(String gehalt, String ort, String bereich, String beschreibung, Integer id);
Run Code Online (Sandbox Code Playgroud)

或者,方法签名不变

@Query (value = "UPDATE vacancy SET salary=?2, location=?3,functionality=?4, description=?5 WHERE id = ?1  ", nativeQuery = true)
Run Code Online (Sandbox Code Playgroud)