Postgres TSVector fields and Hibernate

Hi,

Unfortunately, I have to live with an existing table PostgresSQL with TSVector field mapped to a java String in my Entity. When trying to do a simple insert I have got the following error:

ERROR 8725 — [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: column “searchable_idx” is of type tsvector but expression is of type character varying
Hint: You will need to rewrite or cast the expression.

Does anyone already did this? any hint?

Development environment:
IntelliJ Idea 2018.2.7
Java 8
JPA standard annotations (except for this TSVector stuff)
PostgresSQL 11

You need to use a custom Hibernate Type for TSVector. Check out this article which tells you how to add such a custom type for PostgreSQL.

If you write the custom type, send a Pull Request to the hibernate-types project, so it can be used by other people as well. I can review your type after you send the Pull Request.