Re: UUID datatype

From: Andrew <archa(at)pacific(dot)net(dot)au>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: ntr <kfeezh(at)gmail(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: UUID datatype
Date: 2008-02-18 14:02:20
Message-ID: 47B98FEC.80502@pacific.net.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi All,

This is probably noise to most people by now, so apologies if it is.

I have done some digging around this area, and the following are my
findings:

Using the JDBC 4 Driver via plain java.sql.* libraries, there is no
problem at all with the UUID datatype. I tested with both
java.sql.Statement and java.sql.PreparedStatement objects and String
UUID representations.

I also created a PGuuid object within the PG JDBC Driver to see what it
entailed, and that worked fine as well. However, in my mind, it is
totally superfluous. I can provide the source code if anyone sees value
in it, but I'm of the opinion that there really isn't any work to do in
the driver to support the datatype. Particularly while the UUID
datatype is missing from java.sql.Types, as any solution would be tied
to accessing this datatype via the Driver API rather than the java.sql.*
API, unless anyone can enlighten me on a solution.

The main reason I raised this in the first place was that I wasn't able
to get this to work in Hibernate. So with Hibernate, and various forums
I'd read, I had assumed that the UUID datatype wasn't working at all
through the Driver. However, as I have just described, I was incorrect
with this assumption.

To get Hibernate to work I needed to create a custom Hibernate type.
Additionally, the default Hibernate uuid.hex generator by Gavin King is
not correctly formatted, including when using the separator attribute,
so the DB rejects this format, which is understandable. So I also
created a custom uuid generator that uses Java's random uuid creator.
If there is interest and anyone is struggling with this, I can provide
further details. I see these issues as specific to Hibernate rather
than a problem with the JDBC Driver.

Now that I have worked through the solution, I have no issues if this
request is withdrawn from the wish list. Just cranky with myself that
it has taken two whole days to figure out the solution, three if I
include the initial question and waiting on the response...

Thanks, and you're doing a brilliant job,

Andy

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Paul Tomblin 2008-02-18 14:19:37 Getting "This ResultSet is closed" exceptions
Previous Message Gregory Stark 2008-02-18 11:24:51 Re: Implementing setQueryTimeout()