I don't mean to be pedantic, but String.format("SELECT id FROM %s WHERE (next_run - now() < interval '2 minutes')", tablename);
Chris -----Original Message----- From: Miłosz [mailto:mtyle...@o2.pl] Sent: Saturday, 22 May 2010 12:11 AM To: users@openjpa.apache.org Subject: Re: java.lang.IllegalArgumentException: no-named-params Hi Juraj, The main problem here is that databases don't like providing table names as parameters. If you want to use different tables in a query, you have to concatenate strings: "SELECT id FROM " + tableName + " WHERE (next_run - now() < interval '2 minutes')" Cheers, Milosz > thanks for reply, but your suggested code: > > > Rick Curtis wrote: > > > > Query query = em.createNativeQuery("SELECT id FROM :?1 WHERE (next_run - > > now() < interval '2 minutes')", Long.class); > > query.setParameter(1, HARVEST_SCHEDULES_TABLE); > > > > produces systax error: (i don't know why the exception sais :? and not :?1 , > weird) > > > > > ERROR: syntax error at or near ":" > > Position: 16 {prepstmnt 9497985 SELECT id FROM :? WHERE (next_run - > > now() < interval '2 minutes') > > > > i tried to change it to this: > > > > Query query = em > > .createNativeQuery( > > "SELECT id FROM ?1 WHERE > > (next_run - now() < interval '2 minutes')", > > Long.class); > > > > but its also not working: > > > > > ERROR: syntax error at or near "$1" > > Position: 16 {prepstmnt 8172621 SELECT id FROM ? WHERE (next_run - now() > > < interval '2 minutes') > > > > thanks for some suggestion, Juraj > > -- > View this message in context: > http://openjpa.208410.n2.nabble.com/java-lang-IllegalArgumentException-no-named-params-tp5080072p5083226.html > Sent from the OpenJPA Users mailing list archive at Nabble.com.