javapostgresqljdbc

Simple query fails with: operator does not exist: bigint = character varying with Postgres jdbc


I have simple query:

/* crm_person */ 
        
            select /*query crm_person*/ 
              crm_pers.*
            from crm_person crm_pers
            where 1=1
         and crm_pers.id = ?

And params map:

enter image description here

As result I am getting error - org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying Hint: No operator matches the given name and argument types. You might need to add explicit type casts. Position: 133


Solution

  • For me problem was groovy script, which set parameter id as string if not specified:

    def params = utils.queries.params().put("id", personId).getMap()
    

    so this helped:

    def params = utils.queries.params().put("id", personId as Long).getMap()