• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate wipes out data from the table

 
vij guy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing a strange scenario where the Java hibernate wipes out / deletes the previously stored data in the database when you restart the program.
In the same running session, it works fine. The thing is why it should wipe out even when primary key is in place?
I am committing the data too in class files.


<id name="id">
<generator class="increment"></generator>

</id>

-------------

Transaction tx = null;
Session session = SessionFactoryUtil.getInstance().getCurrentSession();
try {
tx = session.beginTransaction();
session.saveOrUpdate(obj1);
// session.save(icall);
tx.commit();

}

Above 'id' is primary key in the table. Any help would be appreciated.
 
Paul Clapham
Sheriff
Posts: 21984
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the "hbm2ddl.auto" property in your hibernate.cfg.xml file, you'll find it's set to do that.
 
vij guy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot. That solved it!
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!