Search code examples
postgresqlspring-roo

Operator does not exist


When trying to create an entity in a Spring-roo PostGres project, I get the following error :

ERROR org.hibernate.util.JDBCExceptionReporter - ERROR: operator does not exist: integer ~~ unknown
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Position: 433

What could be the solution ?


Solution

  • Type unknown usually occurs when you've a string literal and Postgres ends up trying to decide if it's a varchar, text, literal array, etc.

    Cast your string as needed, e.g.:

    '2'::int
    

    Or don't quote it in the first place, if applicable.