pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Sargent <robjsargent@gmail.com>
To: Alexander Myodov <amyodov@gmail.com>
Cc: pgsql-jdbc@lists.postgresql.org
Subject: Re: (How to) Make SQLData of UUID?
Date: Sun, 21 Jul 2019 16:44:15 -0600
Message-ID: <B5585BA0-BC13-4157-A102-B759E95378E7@gmail.com> (raw)
In-Reply-To: <CAHF95JzG9dAJnmjR000VQMeyLb1+4JsyffDQcSQ5h2LrNTaqHA@mail.gmail.com>
References: <CAHF95JzG9dAJnmjR000VQMeyLb1+4JsyffDQcSQ5h2LrNTaqHA@mail.gmail.com>



> On Jul 21, 2019, at 3:58 PM, Alexander Myodov <amyodov@gmail.com> wrote:
> 
> 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?
> 
> -- 
Can you look into how JOOQ does it in there SQLDataType classes?  It’s worked flawlessly for me.

> Alex Myodov

view thread (5+ messages)  latest in thread

Message-ID: <B5585BA0-BC13-4157-A102-B759E95378E7@gmail.com>
Permalink:  ../B5585BA0-BC13-4157-A102-B759E95378E7@gmail.com/
Also on:    postgresql.org/message-id/B5585BA0-BC13-4157-A102-B759E95378E7@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: robjsargent@gmail.com, amyodov@gmail.com
  Subject: Re: (How to) Make SQLData of UUID?
  In-Reply-To: <B5585BA0-BC13-4157-A102-B759E95378E7@gmail.com>
  References: <CAHF95JzG9dAJnmjR000VQMeyLb1+4JsyffDQcSQ5h2LrNTaqHA@mail.gmail.com> <B5585BA0-BC13-4157-A102-B759E95378E7@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox