繁体   English   中英

我们如何才能获得JPA EntityManager Flush工作

[英]how we can get JPA EntityManager Flush work

我的问题是为什么冲洗不起作用:

public void ejbService(){
   Customer c = em.find(Customer.class,1);
   c.setName("newName");
   em.flush();
   //at this point when I query mysql table I can not see "newName"


   thread.sleep(10000);

   c.setName("anotherName");
}

完成方法后,我在db中看到“anotherName”,我也用em.find(Customer.class,1,Lock.None)检查它; 但仍然不行

RGDS

你正在刷新,但你没有提交 - 或以其他方式结束可能配置为自动提交的事务/会话。

是的,在调用flush() ,DBMS现在知道您的数据 - 但是遵循ACID标准,在DBMS被告知提交之前,没有其他数据库会话会看到这些数据。

如果不了解有关其他应用程序背后的架构的其他详细信息,您可能希望执行以下操作:

em.getTransaction().commit();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM