I'm trying to use the following with spring-data-jdbc and postgres driver (kotlin),
data class MyEntity(
val id: UUID,
val content: String
)
using a string fails with the following error,
org.postgresql.util.PSQLException: ERROR: column "content" is of type jsonb but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Position: 31
I'm not sure how I can use the converter for String -> jsonb
With the help of this I implemented the following solution:
MyContent
)jackson
)org.postgresql.util.PGobject
Details (only pseudo code):
Don't forget to add the two converters to
spring-data-jdbc
s configuration (seeJdbcCustomConversions
).This works with this corresponding postgres table: