Persistence.createEntityManagerFactory清除整个数据库
我目前正在使用Hibernate + JPA的项目。
我不记得我在项目中确切改变了什么,但每当我尝试实例化一个新的EntityManagerFactory时,它都会清除数据库中的所有数据。
这是代码片段:
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();
}
在包含“Persistence.createEntityManagerFactory(”hibernatePersistence“)”的行中,清除整个数据库。
我用尽了解决这个问题的每一个想法...我希望你们能帮忙。
提前致谢!
没有找到相关结果
已邀请:
2 个回复
功飘
属性(可能是
文件)并将其删除或将其值更改为
。也可以看看: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html#configuration-optional
蹄渭信妥扳