jpa取不到最新值

用jpa操作数据库,有时由于并发及一级缓存的问题,导致取到的对象不是最新的,解决办法如下:

1.在service中注入这个对象:

@Autowired

private EntityManager entityManager;

2.将取到的对象,执行以下操作,对象名为:detail

entityManager.refresh(detail);

猜你喜欢

转载自qingwei201314.iteye.com/blog/2410444