hibernate-postgres-jsonb icon indicating copy to clipboard operation
hibernate-postgres-jsonb copied to clipboard

JSONB stores plain text

Open cssatheesh opened this issue 10 years ago • 1 comments

Hi Pires,

I tried playing around with your hibernate-postgres-jsonb. I'm using Spring-JPA and I have a field like this. @TypeDef(name = "jsonb", typeClass = JSONBUserType.class, parameters = { @Parameter(name = JSONBUserType.CLASS, value = "java.lang.String")}) @Entity @Table(name = "ENTITY") class Entity{ @Type(type = "jsonb") private String label; .. } When I pass a json string as given below, it persists them. entity.setLabel("{"label":"full name"}")

I was trying to test an invalid json and was expecting an error. entity.setLabel("invalid json format");

But I see the above value getting persisted in label column in PostgreSQL db.I verified the datatype and the datatype is jsonb.

When I try Java jdbc standalone code to do the same, I get json validation error. Do you have any idea?

cssatheesh avatar Oct 02 '15 20:10 cssatheesh

Can you provide with an example test/project I can test with?

pires avatar Oct 04 '15 10:10 pires