membersound
membersound

Reputation: 86747

How to use named parameters in a native spring-data @Query?

I'm trying to set up a db query using spring-data-jpa and a native query for a postgres database. But the following does not work. Why?

@Query(value = "SELECT reltuples::bigint AS estimate FROM pg_class WHERE oid = 'public.my_table'::regclass", nativeQuery = true)
public int count();

Result:

java.lang.IllegalArgumentException: org.hibernate.QueryException: Not all named parameters have been set: [:bigint, :regclass;] 

Upvotes: 1

Views: 952

Answers (1)

membersound
membersound

Reputation: 86747

Found it: the :: have to be escaped like \\:\\:

Upvotes: 2

Related Questions