jpa - WHERE b.maxOrdini > maxordine throws "The identification variable 'maxordine' is not defined in the FROM clause" -


i tried write query in java ee application:

public list<fornitore> findbymaxordine(int maxordine)  {     query query;     query = em.createquery("select b fornitore b b.maxordini > maxordine");     query.setparameter("maxordine", maxordine);     return query.getresultlist(); } 

when try run result:

exception description: problem compiling [select b fornitore b b.maxordini > maxordine][46, 55] identification variable 'maxordine' cannot used in conjunction > operator.[46, 55] identification variable 'maxordine' not defined in clause. 

i can not understand why not work. help.

since maxordine named parameter, query should rather be:

"select b fornitore b b.maxordini > :maxordine" 

you can use positional parameters, instead of named ones, if wish. then, (re-factored) method like:

public list<fornitore> findbymaxordine(int maxordine) {     return em.createquery("select b fornitore b b.maxordini > ?1")            .setparameter(1, maxordine);            .getresultlist(); } 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -