hibernate-postgres-jsonb
hibernate-postgres-jsonb copied to clipboard
JSONB stores plain text
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?
Can you provide with an example test/project I can test with?