-->
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: Hibernate appears to corrupt '£' smbol
PostPosted: Mon Jan 31, 2011 8:28 am 
Regular
Regular

Joined: Sat Apr 23, 2005 7:28 am
Posts: 52
I'm having a curious problem saving data that includes a £ symbol as a single character in a String variable and I'm not sure how to solve..

When saved, the database field actually contains '£' and not '£'.
If I debug the code, immediately prior to the save, the POJO contains '£' so I am certain it is some Hibernate feature that is adding the extra symbol.

The .hbm.xml defines the property as:
Code:
<property name="currency" type="string">
   <column length="3" name="CURRENCY" not-null="false"/>
</property>


The POJO defines the proerty as:
Code:
private String            currency;                // Size: 3.0, Nullable:true

The database is a Pervasive database for which I have declared a new PervasiveDialect.

The dialect includes the entries:
Code:
registerColumnType(Types.VARCHAR, "char($1)");
registerColumnType(Types.VARCHAR, "varchar($l)");


Any suggestions to help me track down the cause and solution to this problem would be most welcome.


Top
 Profile  
 
 Post subject: Re: Hibernate appears to corrupt '£' smbol
PostPosted: Mon Jan 31, 2011 11:28 am 
Regular
Regular

Joined: Sat Apr 23, 2005 7:28 am
Posts: 52
Problem solved.

After some trial and a lot of error, I discovered that this was a simple codepage issue and that I needed to modify my connection string to include the encoding used by the database:

Code:
<property name="hibernate.connection.encoding">cp1252</property>


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.