3

I have a table member where party is one of the column of type jsonb. jsonb structure looks as below:

{
    "PE": [ "fefe046d-774d-4e8b-a74c-99c89e98a96f",
            "720bfde7-a8c0-404f-b746-d6929c9b1109",
            "409cc84a-a473-4945-9ec0-c09a2ae96395" ],
    "TE": []
}

I have written a query as below in native SQL, how to write the same query using jpa criteria?

select distinct id from public.member,jsonb_array_elements_text(party-> 'PE') where value  in ('fefe046d-774d-4e8b-a74c-99c89e98a96f','409cc84a-a473-4945-9ec0-c09a2ae96395')

Your response at the earliest would be appreciated.

Andy Guibert
  • 41,446
  • 8
  • 38
  • 61
  • Since that method only exists in one database anywhere, and not at all in JPQL (and hence JPA Criteria) then no you can't ... without calling the NATIVE SQL function. Any JPA docs would reveal that –  Jun 01 '18 at 12:31
  • cb.function() can not be used? – Wenaro Dec 04 '18 at 10:21
  • cb.function definitely can be used – adarshr Oct 12 '22 at 16:01

0 Answers0