Question about flushing with JPA before a query is called

白昼怎懂夜的黑 提交于 2019-11-30 23:46:56

In the first case flush is needed as long as User has an autogenerated id, since it's not assigned before flush. If id is not generated, em.find() will return the same instance from the persistence context, so flush is not needed.

In the second case explicit flush is not needed because JPA performs flush before executing a query automatically (if flush mode is AUTO that is by default, otherwise explicit flush is needed).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!