I’m currently working with a project using Hibernate + JPA.
I don’t recall exactly what I changed in the project, but everytime I try to instantiate a new EntityManagerFactory, it clears out all of the data from the database.
Here is the code snippet:
public abstract class GenericDAO<T> {
protected Class<T> t;
protected EntityManagerFactory managerFactory;
protected EntityManager manager;
protected Session hibernateSession;
public GenericDAO(Class<T> t) {
this.t = t;
this.managerFactory = Persistence.createEntityManagerFactory("hibernatePersistence");
this.manager = this.managerFactory.createEntityManager();
this.hibernateSession = HibernateUtil.getSessionFactory().openSession();
}
In the line that contains “Persistence.createEntityManagerFactory(“hibernatePersistence”)”, the whole database is cleared out.
I exhausted every idea for solving this issue… I hope you guys can help.
Thanks in advance!
Look for
hibernate.hbm2ddl.autoproperty somewhere in your project (probablypersistence.xmlfile) and remove it or change its value tovalidate. See also:http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html#configuration-optional