[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[eclipselink-users] Named parameters and createNativeQuery does not work with PostgreSQL
|
Hi.
I have this native-query (I use Scala-JPA, which is a thin wrapper):
entityManager.createNativeQuery[Boolean](
"""SELECT s.is_seen
FROM origo_email_message_property s
WHERE s.owner_id = :ownerId AND s.message_id = :messageId""").
setParams("ownerId" -> owner.id, "messageId" -> messageId)
Which results in this SQLException using PostgreSQL:
Internal Exception: java.sql.SQLException: syntax error at or near ":"
Error Code: 0
Call: SELECT s.is_seen
FROM origo_email_message_property s
WHERE s.owner_id = :ownerId AND s.message_id = :messageId
It seems EL sends the query unmodified to PG and PG doesn't support :<param_name> syntax, only indexed (as in "where id = ?"). Hibernate handles this quite nicely and rewrites the query if necessary it seems.
Is this a known issue using PG and one has to use indexed instead of named params in native-queries?
Thanks.
--
Andreas Joseph Krogh <andreak@xxxxxxxxxxxx> mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc