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
|