Params on NamedNativeQuery

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Params on NamedNativeQuery

John Arevalo
Hi list,

Im working with NamednativeQuery Annotation:

SELECT * FROM City WHERE cityId=':cityId'

but in execution time mi param :cityId is not parsed and query search
rows with id ":cityId" explicitly

does NamedNativeQuery supports params?

Beset regards,
--
John Arévalo
GNU/Linux User #443701
http://counter.li.org/
_______________________________________________
eclipselink-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
tch
Reply | Threaded
Open this post in threaded view
|

Re: Params on NamedNativeQuery

tch
Looks like because you have quotes around the param.

On 12/10/08, Edilson <[hidden email]> wrote:

> Hi list,
>
> Im working with NamednativeQuery Annotation:
>
> SELECT * FROM City WHERE cityId=':cityId'
>
> but in execution time mi param :cityId is not parsed and query search
> rows with id ":cityId" explicitly
>
> does NamedNativeQuery supports params?
>
> Beset regards,
> --
> John Arévalo
> GNU/Linux User #443701
> http://counter.li.org/
> _______________________________________________
> eclipselink-users mailing list
> [hidden email]
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>


--
./tch
_______________________________________________
eclipselink-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
Reply | Threaded
Open this post in threaded view
|

Re: Params on NamedNativeQuery

John Arevalo
Thanks for your reply.

without quotes throws SQLSyntaxException, looks like eclipseLink does
not mapping params, instead is executing plain query.


--
John Arévalo
GNU/Linux User #443701
http://counter.li.org/
_______________________________________________
eclipselink-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
Reply | Threaded
Open this post in threaded view
|

Re: Params on NamedNativeQuery

jamesssss
The JPA syntax for arguments in native queries is "?".

"SELECT * FROM City WHERE cityId=?"

or,
"SELECT * FROM City WHERE cityId=?1"

Named parameters (:name) are not allowed.  Although I agree it is confusing that JPQL allows named parameters, and SQL queries do not, feel free to log a bug for this.

You may also be able to use EclipseLink native argument syntax "#".

"SELECT * FROM City WHERE cityId=#cityId"

Edilson-2 wrote
Thanks for your reply.

without quotes throws SQLSyntaxException, looks like eclipseLink does
not mapping params, instead is executing plain query.


--
John Arévalo
GNU/Linux User #443701
http://counter.li.org/
Reply | Threaded
Open this post in threaded view
|

Re: Params on NamedNativeQuery

John Arevalo
Thanks James, using ?1 params works successfully
--
John Arévalo
GNU/Linux User #443701
http://counter.li.org/
_______________________________________________
eclipselink-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/eclipselink-users