• 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: 21588
33
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic