K. Smith:
Necesito convertir una cadena a un GUID, hay un montón de tutoriales en línea sobre la conversión de uno a un UUID, pero no a un GUID. Estoy trabajando en Java.
Cuando utilizo un UUID, me sale el siguiente error:
ERROR: operator does not exist: character varying = uuid
Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
He intentado usar la ayuda de la siguiente pregunta, pero Guid no parece ser un tipo de Java y el constructor de GUID no toma ningún argumento:
un caballo sin nombre :
Asumiendo que su columna se define como uuid
en Postgres, se puede utilizar java.util.UUID
para eso.
Algo como:
java.util.UUID id = UUID.fromString("....");
PreparedStatement pstmt = connection.prepareStatement("select * from some_table where id = ?");
pstmt.setObject(1, id);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
... do something
}