-->
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: latin1 varchar encoding problem
PostPosted: Tue Dec 13, 2005 4:08 pm 
Newbie

Joined: Tue Dec 13, 2005 3:53 pm
Posts: 2
Hibernate version:
3.1

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.ilrn.controller.upload.data.UsrAte" table="tblUsrAte">
<id name="usrAteID" column="usrAteID">
<generator class="native"/>
</id>
<property name="usrProfileID" type="string"/>
<property name="usrMeal" type="string">
<!-- <column name="usrMeal" sql-type="VARCHAR(20) CHARACTER SET latin1" ></column> -->
<column name="usrMeal" sql-type="VARCHAR(20) COLLATE 'latin1'" ></column>
</property>
</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
UsrAte usrAte = getUsrAte();
currentSession.save(usrAte);

Full stack trace of any exception that occurs:
n/a

Name and version of the database you are using:
mysql 4.1.12

The generated SQL (show_sql=true):
Hibernate: insert into tblUsrAte (usrProfileID, usrMeal) values (?, ?)

So the problem I'm having is that I have a very simple java ojbect mapping to a varchar column. The whole database happens to be using latin1_swedish_ci for Collation. When I perform the a save, I'm getting strange characters in the varchar field. The mapping file that I included is just at the point where I stopped working on this. I've tried just about everything I can think of in that file.

Anyway, any help on this? What's the correct way of setting Collation? Can I do it once? I'm also wondering why I'm having to deal with in general? Maybe I'm missing something, but I'm sorta thinking that this should be handled automagically by hibernate. Maybe I'm just being not understanding what's going on.

Thanks!

--
Marcus


Top
 Profile  
 
 Post subject: not really an ecnoding problem
PostPosted: Wed Dec 14, 2005 2:10 pm 
Newbie

Joined: Tue Dec 13, 2005 3:53 pm
Posts: 2
Well, I'm not sure if it is or not. I'm actually at a loss here. I'm just trying to do a very very simple example ... and it just isn't working at all. So I have a java object with two fields: description and organization. Both are Strings. I have a table, that has and ID (bigint), description (varchar) and organization (varchar). I do a very simple mapping and I perform a save. I see a new entry in the table, but the cols do not contain the correct data. If I only set (on the java objet) the description I get a blank entry (empty string - or rather not null). If I set the description and the organization; the description has this char in it: ý and the organization is now empty (not null). So clearly something is happening, just not the correct thing.

My OS is:

Ubuntu
Linux 2.6.12-10-386 #1 Fri Nov 18 11:51:02 UTC 2005 i686 GNU/Linux

DB:

MySQL 4.1.12

Java:

java version "1.5.0_06"

Anyway ... I'm trying to follow the example code ... so I'm not doing anything different there. I guess I just don't know how to proceed on this ... getting rather frustrated as well.

Thanks.

--
Marcus


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.