H2 UUID type

1,800 views
Skip to first unread message

dodtsair

unread,
Jul 4, 2012, 12:54:15 AM7/4/12
to h2-da...@googlegroups.com
I am a little confused.  When I was using ibatis to generate pojos based on a h2 schema that included UUIDs then the pojos themselves did not use the UUID type.

Now that I am revisiting h2 I am running some plain JDBC code, and the class name h2 uses (getColumnClassName) for the UUID column type is [B.  Which basically means byte[].  Why does h2 give a byte[] as the class name for a UUID column instead of a UUID. 

I read the documentation at
http://www.h2database.com/html/datatypes.html#uuid_type
Which says that the getObject returns type UUID, so just not able to understand the connection between getColumnClassName and getObject(n).getClass()

Noel Grandin

unread,
Jul 5, 2012, 4:30:38 AM7/5/12
to h2-da...@googlegroups.com, dodtsair

getColumnType() will return UUID

getColumnClassName() will return the class that is returned by
getObject(), which is indeed a byte array.
> --
> You received this message because you are subscribed to the Google
> Groups "H2 Database" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/h2-database/-/_owxOUZx6UAJ.
> To post to this group, send email to h2-da...@googlegroups.com.
> To unsubscribe from this group, send email to
> h2-database...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/h2-database?hl=en.


Mike Power

unread,
Jul 11, 2012, 12:36:25 AM7/11/12
to h2-da...@googlegroups.com
I take it there is a reason for not normalizing the APIs that I am not
aware of.

What would it mean for the follow?
1) getColumnType returns UUID
2) getColumnClassName returns java.util.UUID
3) getObject returns instance of UUID

Thomas Mueller

unread,
Jul 13, 2012, 1:42:40 PM7/13/12
to h2-da...@googlegroups.com
Hi,

Unless another database supports java.util.UUID, I don't think I will
support this within H2.

By the way, do you want to create an index on the UUID? Please note
this is problematic, see
http://h2database.com/html/datatypes.html#uuid_type

Regards,
Thomas
> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
Reply all
Reply to author
Forward
0 new messages