-->
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.  [ 1 post ] 
Author Message
 Post subject: Problems with postgres UUID extending postgres dialect
PostPosted: Tue Apr 16, 2013 11:32 am 
Newbie

Joined: Tue Apr 16, 2013 11:16 am
Posts: 1
Hello,

I using PostgreSQL 9.2 and UUID native type.
I am using Hibernate 4 and has some entities using java.util.UUID type.

I expected automatic mapping, zero worries (it worked very well on H2) ... but i get problems since Hibernate try to save a bytea where db expect uuid.

Then i started to search ... and i get the solution of annotate explicitly the field to use pg-uuid type.
sadly this solution does not fits to me ... i cannot do that since i will broke compatibility with other databases.

So i need to do something else ... i figure:
1. Extend postgresql dialect
or
2. Define a custom type that switches the mapping depending on environment variables as here -> https://zorq.net/b/2012/04/21/switching-hibernates-uuid-type-mapping-per-database/

I prefer 1 ... and it seems easier so i tried do this:

public class PostgreSqlCustomDialect extends org.hibernate.dialect.PostgreSQLDialect {
public PostgreSqlCustomDialect() {
super();
registerColumnType(Types.OTHER, "uuid");
registerHibernateType(Types.OTHER, "org.hibernate.type.PostgresUUIDType");
}
}

... but i get the same problem! ... did i made something wrong??

I've also read Hibernate documentation section 6.5 where i see: "To register a new type or to override an existing type registration, applications would make use of the registerTypeOverride method of the org.hibernate.cfg.Configuration class when bootstrapping Hibernate."

Sounds very good ... but i need additional hints on how to achieve this :P

Could someone, please, help me?

Thanks in advance.


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

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.