-->
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.  [ 9 posts ] 
Author Message
 Post subject: Charset issues
PostPosted: Wed Apr 25, 2007 3:12 am 
Newbie

Joined: Sun Jun 25, 2006 9:27 pm
Posts: 18
Hi,
I have some problems with hibernate when trying to use a "String" as my primary key. I am using mysql 5.0.37. I have a collection which is persisted at some point in time and which I scan for duplicates in java. However, hibernate still throws me an exception, treating "Bjorn" the same as "Björn" for example. I have played around with charsets but I cannot get it to work - I get an error like this:
Duplicate entry 'Björn Borg' for key 1


Thanks for your help!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 25, 2007 3:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
thats your database, not hibernate that is complaining.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Charset issues
PostPosted: Wed Apr 25, 2007 10:58 am 
Newbie

Joined: Sun Jun 25, 2006 9:27 pm
Posts: 18
hi,
thanks for your answer max, however, the database supports a feature that allows to store the value in a varchar as a "binary" value rather than a character-sequence. How can I achieve this with hibernate?
thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 25, 2007 6:22 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
how would you do it in jdbc?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Hi
PostPosted: Thu Apr 26, 2007 12:53 pm 
Newbie

Joined: Sun Jun 25, 2006 9:27 pm
Posts: 18
I got it to work with:
@Id @Column(columnDefinition=" varbinary(255) NOT NULL")

While I get less errors now, I still have troubles with duplicate key exceptions... is there a way to just go ahead and leave out the entries of a set that are also merged (due to cascading) and are problematic instead of rejecting the entire transaction?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 1:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no, why should we ignore inconsistent data errors ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 1:46 pm 
Newbie

Joined: Sun Jun 25, 2006 9:27 pm
Posts: 18
yes, I guess you're right. I just don't need to have such a high accuracy, so I will just try and catch and go on...

thanks, though!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 1:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
catching exceptions and ignoring them will leave your state "undefined" ...that can't be what you want.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 2:13 pm 
Newbie

Joined: Sun Jun 25, 2006 9:27 pm
Posts: 18
thanks max!
you're right, but I don't really see a way around this right now. I finally managed to resolve the locale-errors by setting my system locale to UTF-8. Now I am fighting with a last issue that throws exceptions, I opened a separate post for that, regarding different issues with duplicates!
again, thanks a bunch for your help & advise!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.