Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support json and json columns #57

Open
messaoudi-mounir opened this issue Mar 1, 2022 · 3 comments
Open

Support json and json columns #57

messaoudi-mounir opened this issue Mar 1, 2022 · 3 comments

Comments

@messaoudi-mounir
Copy link

messaoudi-mounir commented Mar 1, 2022

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

@perplexhub
Copy link
Owner

Do you have the sql query?

@chriseteka
Copy link
Contributor

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;

@l-martini
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants