PostgreSQL错误处理“operator does not exist: character varying = bytea at character”

PostgreSQL的日志报如下的错误:

2015-05-26 15:34:42.324 CST:(49514):<14753>:[30287041] ERROR:  operator does not exist: character varying = bytea at character 704
2015-05-26 15:34:42.324 CST:(49514):<14753>:[30287041] HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
2015-05-26 15:34:42.324 CST:(49514):<14753>:[30287041] STATEMENT: xxx

从给出的报错对应的SQL中可以定位到是哪个=子句,在网络上查找到对应的信息:

当使用hibernate使用参数绑定,而参数的值为null时,hibernate或者PostgreSQL驱动将这个参数映射为varbinary类型,PostgreSQL将varbinary认为为bytea类型

因此,在代码中特殊地处理值为null的情况,避免将null值传送给PostgreSQL即可。

你可能感兴趣的:(PostgreSQL错误处理“operator does not exist: character varying = bytea at character”)