openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hal Hildebrand <>
Subject OpenJPA PostgreSQL UUID column
Date Fri, 27 Mar 2015 23:28:41 GMT

I’m trying to use the native UUID type for PostgreSQL in my OpenJPA model.  I’m using
OpenJPA 2.3.0 and at the current level of the PostgreSQL JDBC driver.

I’ve tried to accomplish this several times and I’ve gotten a bit further this time. 
I created a ValueHolder (see attached file) and it does what I believe is the correct setup
for this type.  I use this as the strategy for the column - i.e. :


I’ve validated via breakpoint that the UuidValueHolder is indeed called in setup and when
converting values.  I’m at the point of trying to do an insert, and regardless of whether
I use an actual UUID as the return mapping (i.e. no transform) or a string (UUID.toString())
I get the same error:

ERROR: column "id" is of type uuid but expression is of type bytea
  Hint: You will need to rewrite or cast the expression.
  Position: 93 {prepstmnt 1848199707 
INSERT INTO (id, notes, update_date, description, name, 
    VALUES (?, ?, ?, ?, ?, ?) 
[params=(byte[]) [B@9ac8b5b, (null) null, (Timestamp) 2015-03-27 15:20:05.921, (null) null,
(String) CoRE, (byte[]) [B@15b17c95]} [code=0, state=42804]

I believe that this error comes from the postgres jdbc driver, not openJPA.  I’ve even tried
using PGObject, which surprisingly works just fine, but throws the same error.

In my google searches, this has come across as a typical problem, and I’ve only found solutions
for this (hypothesized) for Toplink and Hibernate.  The one thing I could find suggested writing
the ValueHolder and that does work up until the point I try to actually insert in JDBC land.

Note that the UUID is being passed as a byte array.

So my question is, am I doing anything incorrect?  Missing something?  From the error message,
it would appear postgresql wants me to cast the result, but I’m not sure how to accomplish
that in OpenJPA.  It could simply be a red herring.

Any help appreciated, as I simply can’t find a working solution via Der Google

View raw message