These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: UUID / Postgres / Hibernate 3.6.3.Final / jdbc 9.0-801.jdbc4
PostPosted: Fri May 06, 2011 5:42 am 
Newbie

Joined: Tue Jun 05, 2007 9:40 am
Posts: 2
Dear,

I try the UUID type but failed. Following exception:
Code:
Caused by: java.sql.BatchUpdateException: Batch-Eintrag 0 insert into ClassToPersist (name, vorname, uuid) values ('jkfdhjks', NULL, '<stream of 16 bytes>') wurde abgebrochen.  Rufen Sie 'getNextException' auf, um die Ursache zu erfahren.
   at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2598)
   at org.postgresql.core.v3.QueryExecutorImpl$1.handleError(QueryExecutorImpl.java:459)
   at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
   at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2737)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
   ... 16 more

getNextException() =
Code:
org.postgresql.util.PSQLException: FEHLER: Spalte »uuid« hat Typ uuid, aber der Ausdruck hat Typ bytea
  Hinweis: Sie müssen den Ausdruck umschreiben oder eine Typumwandlung vornehmen.
  Position: 66

Code:
SQLState: 42804

My Id Field is annotated as the following:
Code:
@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "uuid2", parameters = { @Parameter(name = "org.hibernate.id.uuid.StandardRandomStrategy", value = "") })
@Column(columnDefinition = "uuid")
private UUID uuid;

I try to insert a UUID with plain jdbc. If I try:
Code:
PreparedStatement ps = DriverManager.getConnection("").prepareStatement("INSERT INTO TABLE (uuid) VALUES (?)");
ps.setObject(1, UUID.randomUUID());
with success. The mapping in the PostgresSQLDialect seems correctly.

My exact Postgres Version is: 8.4.8

Can you please help me? Whats wrong?


Top
 Profile  
 
 Post subject: Re: UUID / Postgres / Hibernate 3.6.3.Final / jdbc 9.0-801.jdbc4
PostPosted: Mon May 09, 2011 10:56 am 
Newbie

Joined: Tue Jun 05, 2007 9:40 am
Posts: 2
Now, I find the solution:
Code:
@Id
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid2")
@Column(name = "uuid")
@Type(type = "pg-uuid")
private UUID uuid;

I try to find a way to config it in a orm.xml but no success. Is there a known way to do this?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.