After I attempt to load an item( a row ) from mysql database, the string qualities aren't loaded correctly , and consequently after i print them, there is nothing displayed.

here's my hibernate config file :

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM 
    <property name="connection.driver_class">
    <property name="connection.url">
    <property name="connection.username">root</property>
    <property name="connection.password"> </property>
    <property name="pool_size">5</property>
    <property name="show_sql">true</property>
    <property name="dialect">
    <!-- Mapping files -->

     <mapping resource="com/navid/Person.hbm.xml"/>


I tryed adding encoding to connection url :


and also got hibernate exception :

Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
    at org.hibernate.cfg.Configuration.doConfigure(
    at org.hibernate.cfg.Configuration.configure(
    at org.hibernate.cfg.Configuration.configure(
    at com.navid.Main.main(
Caused by: org.dom4j.DocumentException: Error on line 10 of document  : The reference to entity "characterEncoding" must end with the ';' delimiter. Nested exception: The reference to entity "characterEncoding" must end with the ';' delimiter.
    at org.hibernate.cfg.Configuration.doConfigure(
    ... 3 more

The hibernate config file is definitely an XML file, so raw &lifier symbols aren't permitted

Two options that come to mind (but untested!), the very first is always to make use of the XML &amp; escape sequence:

<property name="connection.url">

Or using title+value syntax, which wouldn't require the &lifier getting away:

<property name="connection.url" value="jdbc:mysql://localhost:3306/demo_hib_1?useUnicode=true&characterEncoding=UTF-8" />

Observe that I have added a second option too, I want both

Have you try adding

<property name="connection.characterEncoding">UTF-8</property>

to session factory configuration.

From Hibernate documentation:

Arbitrary connection qualities could be distributed by prepending "hibernate.connection" towards the connection property title. For instance, you are able to specify a charSet connection property using hibernate.connection.charSet.