I have a table with a column of type json in my postgreSQL DB (9.2). I'm using Hibernate and implemented the code example from Mapping postgreSQL JSON column to Hibernate value type suggested by Tim Fulmer, But I keep getting the following exception :
ERROR: column "jsonobject" is of type json but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
I don't want to cast the expression because it is not recommended. I getting this error when I'm using a table that was pre-generated and the column is of type json. When I'm changing Hibernate configuration to build the table for me, I don't get the exception and the value are inserted to the newly created table but the type of this column is 'character varying(255)' instead of JSON.
I'm bet that I missed something in my implementation but can't understand what. Where should I look ? I even tried to set breakpoints in my code but I don't reach them.
Thanks.
Found the solution, the following definition was really missing from my project. In the xml mapping file for the table I had to use type="com.example.StringJsonUserType" for that specific field instead of type="java.lang.String" so the mapping for this column is :
Sagi.