Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

[JPA] Toplink + PostgreSQL uuid

682640Jan 30 2009 — edited Sep 20 2010
hey All,

I am not sure if this is the right forum but I have problems with the uuid typo3 in PostgreSQL. For primary keys and foreign references I use the postgreSQL UUID type. This works perfectly with JDBC, but not so much with Toplink/JPA

I annotated my ID much like this:

@Id
@Basic(optional = false)
@Column(name = "item_id", columnDefinition="uuid")
@GeneratedValue(strategy=GenerationType.SEQUENCE)
private String itemId;
@Column(name = "page_item_id", columnDefinition="uuid")
private String pageItemId";

But each time when I try to create a record I get this error message:
Internal Exception: org.postgresql.util.PSQLException: ERROR: column "page_item_id" is of type uuid but expression is of type character varying
Error Code: 0
Call: INSERT INTO tbl_domains (redirect_code, page_item_id, redirect_url, ssl_mode, domain_name, port) VALUES (?, ?, ?, ?, ?, ?)
bind => [0, null, null, false, Ries3, 0]

I am ok with the fact that my UUID enters my java class as a string, I might compare them but they will always be generated by the DB, and never by my application.

How can I tell JPA/TopLink to cast page_item_id to a uuid and not to a string during database inserts/updates?

Kind Regards,
Ries van Twisk
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 18 2010
Added on Jan 30 2009
4 comments
5,476 views