0

hibernate がテーブルを作成できないのはなぜですか?

<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

1 に答える 1

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

このため、そのたびにテーブルをドロップして作成します。

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

updateの代わりに使用しcreateます。

于 2013-07-27T14:23:45.787 に答える