Java JPA - "Query argument id not found in the list of parameters provided during query execution" -
i have entity class called pilot following defined named query:
@namedquery(name="pilot.findbyid", query="select p pilot p p.id = :id") and 1 called flight named query:
@namedquery(name="flight.findbyid", query="select f flight f f.id = :id") then have method following:
typedquery<flight> fquery = em.createnamedquery("flight.findbyid", flight.class); fquery.setparameter("id", integer.parseint(flightid)); flight f = fquery.getsingleresult(); typedquery<pilot> pquery = em.createnamedquery("pilot.findbyid", pilot.class); fquery.setparameter("id", integer.parseint(pilotid)); pilot p = pquery.getsingleresult(); but reason when call error:
... caused by: java.lang.illegalstateexception: query argument id not found in list of parameters provided during query execution. ... what problem?
looks cut , paste error...
typedquery<pilot> pquery = em.createnamedquery("pilot.findbyid", pilot.class); fquery.setparameter("id", integer.parseint(pilotid)); ^^^^^^ you setting id on fquery twice. try changing 1 pilots pquery. this:
typedquery<pilot> pquery = em.createnamedquery("pilot.findbyid", pilot.class); pquery.setparameter("id", integer.parseint(pilotid)); ^^^^^^
Comments
Post a Comment