Nav*_*Nav 17 java jpa transactions entitymanager
我的问题是为什么冲洗不起作用:
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");
}
Run Code Online (Sandbox Code Playgroud)
完成方法后,我在db中看到"anotherName",我也用em.find(Customer.class,1,Lock.None)检查它; 但仍然不行
RGDS
zie*_*mer 23
你正在刷新,但你没有提交 - 或以其他方式结束可能配置为自动提交的事务/会话.
是的,在调用之后flush()
,DBMS现在知道您的数据 - 但是遵循ACID标准,在DBMS被告知提交之前,没有其他数据库会话将看到此数据.
如果不了解其他应用程序背后的架构的其他详细信息,您可能希望执行以下操作:
em.getTransaction().commit();
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
16270 次 |
最近记录: |