Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hpKZ5-0004t6-GU for pgsql-jdbc@arkaria.postgresql.org; Sun, 21 Jul 2019 22:44:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hpKZ4-0003J5-8g for pgsql-jdbc@arkaria.postgresql.org; Sun, 21 Jul 2019 22:44:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hpKZ3-0003If-Vz for pgsql-jdbc@lists.postgresql.org; Sun, 21 Jul 2019 22:44:22 +0000 Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hpKZ1-0008IC-PM for pgsql-jdbc@lists.postgresql.org; Sun, 21 Jul 2019 22:44:21 +0000 Received: by mail-io1-xd36.google.com with SMTP id e20so39512500iob.9 for ; Sun, 21 Jul 2019 15:44:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=JKX0PNruyVEeWvFCt+QLO7TYmsYldxHXTgVUrCWuqF8=; b=CnpVAZFpUfCBQmM3bDDY6h3CrHBOXyWvETxOESiWhgYeJnLVGV2dfABmMps+LqquhR QuWItgE2QZ/zzejAammwVmNW1n/aNpSkMN7igytJsuuSi8i2P7cqrJu8xXqTGop6ab3m fLlUwEX8L+Dm1yyHJAq536qQ1uWQEFc1a9K+0oW40WD5Y6K46DJk4MwdlxYVuCzoxnIp MlAOIo6o6LgwCXs1jyjUAolIP/lgQVa1UMlA0lczCw27Nh1hQsxe+CtSXrXjh+y+whtn KYOt9dQQ59lSvE087JME1DkxXsK4O3gEldRdRXf3u1TJjGAcjskp5d3w/woqjZZ2RFQA ClAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=JKX0PNruyVEeWvFCt+QLO7TYmsYldxHXTgVUrCWuqF8=; b=o6P5mQS3kM92eTUPvZJCvmiIdm2RAixe6sCRMTr0K4AhT/Hkfz1TINv9S3zP+dqIM/ RJxjUcevHBEN+tc0ys3oea3zek0C4G+1feC6hFu8XLirfcM0urPAJVKbZLLWa2yQAwLe qEEj6S1LpPzLr+aBmNlq53RQGYIgGK5jZ1ZubSRK2jiVXSNVizxl87kqvpkg470F0CIH QeexjQ6v4ZMbnVJ4xX8J6bK4+Hl4N4mFFKnADherliyvLwkvAWn1pQiGsPYplEv9YnPN jwxh2my70gUpzz09MfE1tzPG5tBIE4hpTW59wYCQrBQUSQfDqyBJ9FRpJ69jQadUsKDh BfxQ== X-Gm-Message-State: APjAAAVQWWysENHabIDo30lY7zTGVLiLQxYChIBojjhxc0aK4dyHdyCH 4Le4QIyw/aQjUpasJGQauCc= X-Google-Smtp-Source: APXvYqx05VszYYbFAMAQc96T44w7HqZ9aLsrYrSbFULTKp9vjocMiAe7KcIlAHZNy9XLvVRVe4kn7Q== X-Received: by 2002:a02:1087:: with SMTP id 129mr72165850jay.131.1563749056631; Sun, 21 Jul 2019 15:44:16 -0700 (PDT) Received: from [192.168.1.108] (c-73-63-59-118.hsd1.ut.comcast.net. [73.63.59.118]) by smtp.gmail.com with ESMTPSA id b20sm30454045ios.44.2019.07.21.15.44.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Jul 2019 15:44:16 -0700 (PDT) From: Rob Sargent Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_D6B8AAC8-BCA0-4DED-ADBA-75087DAB6FCF" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: (How to) Make SQLData of UUID? Date: Sun, 21 Jul 2019 16:44:15 -0600 In-Reply-To: Cc: pgsql-jdbc@lists.postgresql.org To: Alexander Myodov References: X-Mailer: Apple Mail (2.3445.104.11) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_D6B8AAC8-BCA0-4DED-ADBA-75087DAB6FCF Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jul 21, 2019, at 3:58 PM, Alexander Myodov = wrote: >=20 > Hello! >=20 > 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. >=20 > Imagine I made a custom type returned from some PL/PgSQL function: >=20 > CREATE TYPE MYFUNC_RETURN_TYPE AS=20 > ( > key UUID > ); >=20 > 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=E2=80=99ll need to implement void = writeSQL(SQLOutput stream) method, and at some point I=E2=80=99ll 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. >=20 > But UUID doesn=E2=80=99t satisfy SQLData interface in any way; and if = I use the second method, I do not have a proper SQLType for UUID = anywhere. >=20 > 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. >=20 > Any hints please? >=20 > --=20 Can you look into how JOOQ does it in there SQLDataType classes? It=E2=80= =99s worked flawlessly for me. > Alex Myodov --Apple-Mail=_D6B8AAC8-BCA0-4DED-ADBA-75087DAB6FCF Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

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=E2=80=99ll = need to implement void = writeSQL(SQLOutput stream) method, and at some point I=E2=80=99ll = 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=E2=80=99t 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=E2=80=99s worked = flawlessly for me.

Alex = Myodov

= --Apple-Mail=_D6B8AAC8-BCA0-4DED-ADBA-75087DAB6FCF--