rsql-jpa-specification icon indicating copy to clipboard operation
rsql-jpa-specification copied to clipboard

Support json and json columns

Open messaoudi-mounir opened this issue 2 years ago • 3 comments

Hi, i use vladmihalcea/hibernate-types to define json and jsonb columns using Postgresql as database.

Here an example:

`

@TypeDefs({ @TypeDef(name = "jsonb", typeClass = JsonBinaryType.class), @TypeDef(name = "json", typeClass = JsonNodeStringType.class) }) public class MyEntity {

.. .. @Column(name = "segment", columnDefinition = "jsonb") @Type(type = "jsonb") private Set< String > segment; ... .. `

The filter is not working ?filter=segment=like=test and i get an error: "com.fasterxml.jackson.core.JsonParseException: Unexpected character ('%' (code 37)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: (String)\"%[test]%\"; line: 1, column: 2]; nested exception is java.lang.IllegalArgumentException: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('%' (code 37)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: (String)\"%[test]%\"; line: 1, column: 2]"

Is there any way to support json/jsonb columns types query ?

thanks

messaoudi-mounir avatar Mar 01 '22 16:03 messaoudi-mounir

Do you have the sql query?

perplexhub avatar Aug 03 '22 17:08 perplexhub

It is interesting this issue is open already, I had a need for this, and will like to research it in my free time.

Do you have the sql query? I saw some sample queries here.

-- Give me params.name (text) from the events table
select params->>'name' from events;

-- Find only events with a specific name
select * from events where params->>'name' = 'Click Button';

-- Give me the first index of a JSON array
select params->ids->0 from events;

-- Find users where preferences.beta is true (boolean)
-- This requires type casting preferences->'beta' from json to boolean
select preferences->'beta' from users where (preferences->>'beta')::boolean is true;

chriseteka avatar Feb 01 '23 09:02 chriseteka

Hi, many thanks for this wonderful lib.

Is there no plan in the short future to add support for jsonb columns? @perplexhub Did you find some workaround to get your job done? @chriseteka

Many thanks

l-martini avatar Apr 18 '23 15:04 l-martini