(How to) Make SQLData of UUID? - Mailing list pgsql-jdbc

From Alexander Myodov
Subject (How to) Make SQLData of UUID?
Date
Msg-id CAHF95JzG9dAJnmjR000VQMeyLb1+4JsyffDQcSQ5h2LrNTaqHA@mail.gmail.com
Whole thread Raw
Responses Re: (How to) Make SQLData of UUID?  (Rob Sargent <robjsargent@gmail.com>)
Re: (How to) Make SQLData of UUID?  (Basil Bourque <basil.bourque@gmail.com>)
(How to) Make composite PGObject with Text? (Was: (How to) MakeSQLData of UUID?)  (Alexander Myodov <amyodov@gmail.com>)
List pgsql-jdbc
Hello!

I seem to miss something obvious maybe, but I cannot find a way to use UUID as SQLData; for example, to make a proper JDBC handling of custom PostgreSQL type containing an UUID.

Imagine I made a custom type returned from some PL/PgSQL function:

CREATE TYPE MYFUNC_RETURN_TYPE AS 

(

  key UUID

);


Now, to handle it in JDBC, I need to make a custom type like MyfuncReturnType implements SQLData, and then add it to the type map of the connection. In MyfuncReturnType, I’ll need to implement void writeSQL(SQLOutput stream) method, and at some point I’ll need to do something like this: to call either

SQLOutput::writeObject(SQLData x)

or

SQLOutput::writeObject(Object x, SQLType targetSqlType),

passing my UUID in somehow.


But UUID doesn’t satisfy SQLData interface in any way; and if I use the second method, I do not have a proper SQLType for UUID anywhere.


I previously used the pgjdbc-ng driver, and they had a collection of postgresql-specific SQLType's; but that driver had other problems, so I decided to switch to the mainstream JDBC driver, and faced this lack.


Any hints please?


--
Alex Myodov

pgsql-jdbc by date:

Previous
From: Hajar Razip
Date:
Subject: [pgjdbc/pgjdbc] c30556: docs: add note on behavior ofResultSet.getString(...
Next
From: Rob Sargent
Date:
Subject: Re: (How to) Make SQLData of UUID?