15
我的問題是,爲什麼刷新不起作用:我們怎樣才能JPA 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");
}
整理我看「anotherName」在DB 的方法後還我em.find檢查( Customer.class,1,Lock.None);但還是不行
RGDS
究竟什麼是齊平的使用? – Nav 2012-01-14 17:00:19
我也將刷新模式更改爲提交而不是自動但沒有任何反應 – Nav 2012-01-14 17:02:33
大多數JPA實現將在JVM中(在EntityManager內)緩存操作。 flush()只會強制將這些操作發送到數據庫等,但並不意味着提交。 http://stackoverflow.com/questions/4275111/correct-use-of-flush-in-jpa-hibernate有一些額外的細節/討論可能對你有所幫助。 – ziesemer 2012-01-14 17:03:15