openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <curti...@gmail.com>
Subject Re: java.lang.IllegalArgumentException: no-named-params
Date Thu, 20 May 2010 15:39:24 GMT
With native queries you need to use indexes for parameters. I'm not sure why
the message "no-named-params" wasn't translated into the proper message...
I'll try to take a look at that when I get a chance.

Query query = em.createNativeQuery("SELECT id FROM :?1 WHERE (next_run -
now() < interval '2 minutes')", Long.class);
query.setParameter(1, HARVEST_SCHEDULES_TABLE);

Thanks,
Rick

On Thu, May 20, 2010 at 10:00 AM, duro <juraj.petko@gmail.com> wrote:

>
> Hello, when i try to set parameter to a query like this:
> Query query = em
>                                .createNativeQuery(
>                                                "SELECT id FROM :table WHERE
> (next_run - now() < interval '2
> minutes')",
>                                                Long.class);
>                query.setParameter("table", HARVEST_SCHEDULES_TABLE);
>
> i get this error:
>
> Exception in thread "Thread-1" java.lang.IllegalArgumentException:
> no-named-params
>        at
> org.apache.openjpa.persistence.QueryImpl.setParameter(QueryImpl.java:1066)
>        at
> org.apache.openjpa.persistence.QueryImpl.setParameter(QueryImpl.java:79)
>
> what am i doing wrong? thanks a lot
>
> ps: using openjpa 2.0.0
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/java-lang-IllegalArgumentException-no-named-params-tp5080072p5080072.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message