-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate, Greek characters and MySQL 5.0
PostPosted: Thu Mar 02, 2006 5:38 am 
Newbie

Joined: Sun Feb 19, 2006 2:46 pm
Posts: 6
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&amp;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


Top
 Profile  
 
 Post subject: It seems that it's the driver
PostPosted: Thu Mar 02, 2006 5:54 am 
Newbie

Joined: Sun Feb 19, 2006 2:46 pm
Posts: 6
...but haven't figured it out yet


Top
 Profile  
 
 Post subject: Found the solution
PostPosted: Thu Mar 02, 2006 7:49 am 
Newbie

Joined: Sun Feb 19, 2006 2:46 pm
Posts: 6
It's me again. It seems that the problem is solved. It was the Eclipse default text file encoding the problem.

Preferences|General|Editor|Text File Encoding.

I set it to UTF-8 and everything is fine.


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