2013-07-27 153 views
0

hibernate無法創建表爲什麼......?無法使用休眠創建表MySQL

<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> 
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/e_shop</property> 
    <property name="hibernate.connection.username">root</property> 
    <property name="hibernate.hbm2ddl.auto">create</property> 
    <property name="hibernate.show_sql">true</property> 

AnnotationConfiguration cfs=new AnnotationConfiguration(); 
     cfs.configure("daoHibernate/hibernate.cfg.xml"); 
     new SchemaExport(cfs).create(true,true); 

我所有的表都得到改變,並表越來越下降,然後再創建爲什麼如何啓動一個新的會話,請給予答覆

回答

4
<property name="hibernate.hbm2ddl.auto">create</property> 

因爲這樣,每次它會刪除並創建表。

<property name="hibernate.hbm2ddl.auto">update</property> 

使用update而不是create