pires / hibernate-postgres-jsonb

A working implementation of JSONB support on a Java + Hibernate application.
Apache License 2.0
63 stars 26 forks source link

JSONB stores plain text #1

Open cssatheesh opened 9 years ago

cssatheesh commented 9 years ago

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?

pires commented 9 years ago

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