postgres的最新Java JDBC驱动程序声称本机支持UUID; 与Postgres 9.2(mac)对抗.
实际上,当使用PreparedStatement时,我可以单步执行驱动程序代码,甚至可以遍历AbstractJdbc3gStatement.java中专门的"setUuid"函数.根据所有迹象,它应该"正常工作".
但是,它不起作用.数据库收回错误,我收到错误:
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: uuid = bytea
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Position: 139
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2157) ~[postgresql-9.2-1002.jdbc4.jar:na]
Run Code Online (Sandbox Code Playgroud)
是的,确实,JDBC驱动程序中的setUuid会将其作为bytea发送:
private void setUuid(int parameterIndex, UUID uuid) throws SQLException {
if (connection.binaryTransferSend(Oid.UUID)) {
byte[] val = new byte[16];
ByteConverter.int8(val, 0, uuid.getMostSignificantBits());
ByteConverter.int8(val, 8, uuid.getLeastSignificantBits());
bindBytes(parameterIndex, val, Oid.UUID);
} else {
bindLiteral(parameterIndex, uuid.toString(), Oid.UUID);
}
}
Run Code Online (Sandbox Code Playgroud)
是什么赋予了?实际数据库中是否需要一些魔法符文来祝福这种转换?