Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0.5
Mapping documents: 7 but we only care about one which is Town.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"C:/java_lib/hibernate/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class name="com.mrc.model.Town" table="town">
<meta attribute="class-description" inherit="false">
@hibernate.class table="town"
</meta>
<meta attribute="extends" inherit="false">
com.mrc.util.AbstractBO
</meta>
<id name="id" type="java.lang.Long" column="id" unsaved-value="null">
<meta attribute="field-description">
@hibernate.id generator-class="native"
type="java.lang.Long" column="id"
</meta>
<generator class="native" />
</id>
<property name="nameEn" type="java.lang.String" column="name_en"
not-null="true" length="50">
<meta attribute="field-description">
@hibernate.property column="name_en" length="50"
not-null="true"
</meta>
</property>
<property name="nameGr" type="java.lang.String" column="name_gr"
not-null="true" length="50">
<meta attribute="field-description">
@hibernate.property column="name_gr" length="50"
not-null="true"
</meta>
</property>
<property name="dateCreated" type="java.util.Date"
column="date_created" not-null="true" length="19">
<meta attribute="field-description">
@hibernate.property column="date_created" length="19"
not-null="true"
</meta>
</property>
<property name="version" type="java.util.Date" column="version"
length="19">
<meta attribute="field-description">
@hibernate.property column="version" length="19"
</meta>
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Town town = new Town( );
town.setNameEn( "Athens" );
town.setNameGr( "Αθήνα" );
session.save( town );
Name and version of the database you are using:MySQL 5.0.15 and J/Connector 3.1.10
The generated SQL (show_sql=true):For some reason I can see only SELECTS
Hello,
My problem has to do with the encoding. As you will see below the DBMS is using UTF8. I also added the parameters to the URL connection in the configuration XML but nothing.
The url is:
jdbc:mysql://localhost/mrc_db?useUnicode=true&characterEncoding=utf8
mysql> show variables like 'c%';
+--------------------------+---------------------------------------------------------+
| Variable_name | Value |
+--------------------------+---------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | C:\Program Files\MySQL\MySQL Server 5.0\share\charsets/ |
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
| completion_type | 0 |
| concurrent_insert | 1 |
| connect_timeout | 5 |
+--------------------------+---------------------------------------------------------+
13 rows in set (0.00 sec)
The resulted record from the "session.save(town);" statement is this:
| 6 | Athens | ????? | 2006-03-02 11:25:24 | 2006-03-02 11:25:24 |
As you can see for "Αθήνα" I get "?????". The database is OK I suppose since when adding a record from the MySQL Query Browser the greek characters are fine.
Can someone please give me a helping hand?
Thank you in advance