Skip to content
Advertisement

Error while getting sql record using EntityManager

I am using EntityManager in spring boot app to get result from this query

JavaScript

Its giving me correct output in PgAdmin but in java code List resultList = em.createNativeQuery(str).setParameter(1, sectionId ).getResultList();

Giving error ERROR: syntax error at or near ":" its breaking at data::jsonb .How do handle this using EntityManager.

Advertisement

Answer

You need to CAST like CAST(c.data as jsonb)->>'product_id' from string to JSONB. However i would highly suggest that you don’t use TEXT for your JSON type data.

JavaScript

`

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement