Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Parameter with that position [1] did not exist; nested exception is java.lang.IllegalArgumentException: Parameter with that position [1] did not exist

Ask Question

I am using JPA Repository[ Using Spring Data ] to query my database in order to return me a list of events that occurred between the dates I submited. I have class with the following variables that will serve as a request body( @RequestBody ) in the controller:

// NOTE -> My Date must be a String

private String initialDate;
private String finalDate;

I pass the following values int POSTMAN

"initialDate":"2018-09-29", "finalDate":"2018-09-30"

This is my correspondent Model class

private String initialDate;
private String finalDate;
private String moreInfo;
private String SomeMoreInfo;

I would like the API to return me the info between those dates, for that I use the following query in my repository layer.

@Query("SELECT u from Kitchen u WHERE STR_TO_DATE(u.date, '%a, %c %b %Y %k:%i:%s') between :initial_day AND :final_day")            
    List<Cozinha> findPlateByDate(@Param("initial_day") String initial_day,@Param("final_day") String final_day);

The following error appears in POSTMAN [as posted in the title of the question]

 "message": "Parameter with that position [1] did not exist; nested exception is java.lang.IllegalArgumentException: Parameter with that position [1] did not exist",

The following error appears in netbeans server console

Caused by: java.lang.IllegalArgumentException: Parameter with that position [1] did not exist

My question is, I am doing the query right? Our the syntax wrong?

I have a hunch that this might be a bug in Spring Data JPA. Could you post the full stack trace and also which version of Spring Data JPA you are using? – Jens Schauder Oct 1, 2018 at 7:51

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.