0

hibernate is not able to create a table why...?

<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);

my all table are getting alter and table getting drop then again created why how to start a new session please give a reply

alok
  • 11
  • 6

1 Answers1

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

because of this, each time it will drop and create tables.

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

use update instead of create.

Ruchira Gayan Ranaweera
  • 34,993
  • 17
  • 75
  • 115