我有一个代码调用另一个api来更新我也使用的同一个表中的数据。我的问题是,即使在实体管理器上调用刷新后,我也看不到数据在我身边刷新。我启用了hibernate跟踪日志记录,我可以清楚地看到那里的查询以及绑定跟踪中的响应值。问题是陈旧的数据。我100%确定更新已提交给db(我们在返回之前在其他api中进行了睡眠,我可以手动查询数据库以查看它在我得到响应之前已更新)
public void func(SomeEntity someEntity){ // this entity was found by entity manager previously
LOGGER.info("SomeEntity before call to API {{}}",someEntity.toString());
String url = "....some get http url which modifed the table "
HttpGet httpGet = new HttpGet(url);
HttpResponse response = client.execute(httpGet);
//..check response etc...
entityManager.refresh(someEntity);
LOGGER.info("Reloaded SomeEntity after call to return creation API {{}}",someEntity.toString()); // same old data here
}