Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: [JDBC] UUID datatype

From: Andrew <archa(at)pacific.net.au>
Date: Mon Feb 18 2008 - 09:02:20 EST


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...

Do you need help?X

Thanks, and you're doing a brilliant job,

Andy

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at
                
http://www.postgresql.org/about/donate
Received on Mon Feb 18 09:03:18 2008

This archive was generated by hypermail 2.1.8 : Wed Jun 18 2008 - 23:44:40 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library