views:

1421

answers:

1

Hi every one, this is My hibernate.hbm.xml and I use MySQL

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
<hibernate-configuration>
    <session-factory>

        <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/dbName?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=UTF-8</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">******</property>

        <property name="hbm2ddl.auto">update</property>
        <property name="hibernate.connection.useUnicode">true</property>
        <property name="hibernate.connection.characterEncoding">UTF-8</property>


        <property name="show_sql">true</property>
        <property name="format_sql">true</property>
        <property name="hibernate.use_sql_comments">true</property>
        <property name="current_session_context_class">thread</property>

        <!-- configuration pool via c3p0-->
        <property name="c3p0.acquire_increment">1</property>
        <property name="c3p0.idle_test_period">100</property> <!-- seconds -->
        <property name="c3p0.max_size">100</property>
        <property name="c3p0.max_statements">0</property>
        <property name="c3p0.min_size">10</property>
        <property name="c3p0.timeout">100</property> <!-- seconds -->
        <!-- DEPRECATED very expensive property name="c3p0.validate>-->


    </session-factory>
</hibernate-configuration>

when I run my program for first time it creates Table in database but my problem is the Charset still is latin1_swedish_ci (latin) and don't be utf8 what should I change in hibernate.hbm.xml settings?

A: 

The UTF-8 setting relates to the way that Hibernate configures its runtime connections to the database. I'm guessing it has no effect on the schema creation stuff, which is really a separate part of Hibernate altogether.

I find that the auto-DDL stuff is only really useful for generating an initial stab at the schema. I always take that DDL and modify it to be exactly what I want.

skaffman
can you explain more about auto-DDL and and how should I use it?
Am1rr3zA
and why hibernate unserstand tht I want create InnoDB schema?coz defualt was MyISAM but when I use org.hibernate.dialect.MySQL5InnoDBDialectit's change it to InnoDB!!!
Am1rr3zA
I'm referring to the hbm2ddl.auto setting you're using in your config.
skaffman