How to make Hibernate not drop tables -



How to make Hibernate not drop tables -

i using hibernate , whenever seek add together record, drops table , adds it. never uses existing table , create changes on that.

this relevant part of hibernate.cfg.xml:

<hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">org.apache.derby.jdbc.clientdriver</property> <property name="hibernate.connection.url">jdbc:derby://localhost:1527/sample</property> <property name="hibernate.connection.username">user</property> <property name="hibernate.connection.password">password</property> <property name="hibernate.connection.pool_size">10</property> <property name="show_sql">true</property> <property name="dialect">org.hibernate.dialect.derbydialect</property> <property name="hibernate.hbm2ddl.auto">update</property> <property name = "current_session_context_class">thread</property> <!-- mapping entities --> <mapping class="inputdetails.table1"/> <mapping class="inputdetails.table2"/> <!--mapping resource="contact.hbm.xml"/--> </session-factory> </hibernate-configuration>

this how save data:

sessionfactory mill = new configuration().configure().buildsessionfactory(); session session = factory.getcurrentsession(); session.begintransaction(); ... session.save(newrecord) session.gettransaction().commit();

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

tells hibernate update database schema each time session mill created.

and

sessionfactory mill = new configuration().configure().buildsessionfactory();

builds new session factory.

a sessionfactory should built 1 time during wole application lifetime. should created 1 time , reused. have read hibernate reference manual?

hibernate

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -