Re: UUID datatype - Mailing list pgsql-jdbc

From Andrew
Subject Re: UUID datatype
Date
Msg-id 47B98FEC.80502@pacific.net.au
Whole thread Raw
In response to Re: UUID datatype  (Kris Jurka <books@ejurka.com>)
List 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





pgsql-jdbc by date:

Previous
From: Gregory Stark
Date:
Subject: Re: Implementing setQueryTimeout()
Next
From: "Paul Tomblin"
Date:
Subject: Getting "This ResultSet is closed" exceptions