I più recenti driver JDBC Java per postgres dichiarano di supportare gli UUID in modo nativo; lavorare contro Postgres 9.2 (mac).Postgres UUID JDBC non funzionante
In effetti, quando si utilizza un PreparedStatement, è possibile scorrere il codice del driver e persino camminare su tramite la funzione "setUuid" specializzata in AbstractJdbc3gStatement.java. Con tutte le indicazioni, dovrebbe "funzionare".
Tuttavia, non funziona. Il database getta indietro un errore che ricevo così:
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]
Sì, in effetti, setUuid nel driver JDBC fa inviare che come 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);
}
}
Che cosa dà? C'è qualche runa magica richiesta nel database reale per benedire questa conversione?
Puoi pubblicare il PreparedStatement reale che si sta tentando di eseguire? – Rafael