Re: UUID column type in PostgreSQL

1,412 views
Skip to first unread message

Lukas Eder

unread,
Sep 1, 2012, 2:42:06 AM9/1/12
to jooq...@googlegroups.com
> My team have problem with fetching data from tables containing uuid column
> type? Does that data type is support by Jooq or how implement fetching data
> to string type?

More formal support for UUID types is on the roadmap:
https://github.com/jOOQ/jOOQ/issues/1624

Currently, I suggest you have this type treated as VARCHAR / String.
What type of problems are you running into?

Cheers
Lukas

Lukas Eder

unread,
Dec 26, 2012, 11:39:53 AM12/26/12
to jooq...@googlegroups.com
Hello,

Already today, you can use org.jooq.Converter types to convert some of
your database columns to UUID's. Please consider the relevant sections
of the manual for this:

Runtime conversion
http://www.jooq.org/doc/2.6/manual/sql-execution/fetching/data-type-conversion/

Code-generation time conversion
http://www.jooq.org/doc/2.6/manual/code-generation/custom-data-types/

Formal UUID support for Postgres, SQL Server and some other databases
that natively support such a type is on the roadmap:
https://github.com/jOOQ/jOOQ/issues/1624

Cheers
Lukas

2012/12/26 adela <ad...@oax.com>:
> I am also trying to use UUID (as Primary Key) in PostgreSQL DB. It would be
> nice to have native java.util.UUID support
> (via JOOQ) for many reasons such as type safety, performance,...and less
> code trying to convert/validate UUID correctness to/from DB....

adela

unread,
Dec 28, 2012, 7:07:23 PM12/28/12
to jooq...@googlegroups.com
Lukas,

You are awesome!  Keep up the good work!  Thank you...That would be really nice to have in today's distributed environments!

Lukas Eder

unread,
Jan 5, 2013, 4:27:05 AM1/5/13
to jooq...@googlegroups.com, ad...@oax.com
It seems that the Postgres JDBC driver natively supports java.util.UUID through ResultSet.getObject() and PreparedStatement.setObject(). Adding support seems as simple as adding an org.jooq.impl.SQLDataType.UUID that maps the "uuid" type name to the java.util.UUID class.

This will be implemented in jOOQ 3.0 and has a high chance of being backported to 2.7. I will see if UUID types can be supported for all databases through jOOQ's internal type mapping

Cheers
Lukas


2012/12/29 adela <ad...@oax.com>

Lukas Eder

unread,
Jan 6, 2013, 8:12:50 AM1/6/13
to jooq...@googlegroups.com
UUID support is implemented on github master. These databases have native support for such a type:

- SQL Server uniqueidentifier data type: http://msdn.microsoft.com/en-us/library/ms187942
- Sybase SQL Anywhere also supports it

In other databases, jOOQ allows for mapping the java.util.UUID type to a CHAR/VARCHAR columns. Implementations that map UUIDs to BINARY(16) can be achieved through custom data types using Converters

Cheers
Lukas


2013/1/5 Lukas Eder <lukas...@gmail.com>

adela

unread,
Jan 7, 2013, 10:26:23 AM1/7/13
to jooq...@googlegroups.com
Very nice Lukas!  I will check out!

Lukas Eder

unread,
Jan 7, 2013, 12:27:17 PM1/7/13
to jooq...@googlegroups.com
> Very nice Lukas! I will check out!

Note, I have just now published an updated SNAPSHOT on the sonatype
snapshot repository:
https://oss.sonatype.org/content/repositories/snapshots/org/jooq/

Cheers
Lukas
Reply all
Reply to author
Forward
0 new messages