在使用FlushModeType.AUTO进行本机查询之前,JPA不会刷新 [英] JPA not flushes before native query with FlushModeType.AUTO

查看:237
本文介绍了在使用FlushModeType.AUTO进行本机查询之前,JPA不会刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的项目中,我们使用hibernate 5.0.12和Spring数据Jpa.我发现jpa不会在本机查询之前调用flush.但是在JPA规范中,我使用FlushModeType读取了它.AUTO flush()在每个查询之前调用(JPQL或本机SQL).我猜它在休眠版本中处于休眠状态.有人可以澄清这个问题吗?我们在此问题上有很多疑问.

In our project we use hibernate 5.0.12 and Spring data Jpa.I found that jpa does not invoke flush before native query.But in JPA specification i read that with FlushModeType.AUTO flush() invokes before every query(JPQL or native SQL).i guess its problem in hibernate an hibernates version.Could someone clarify this problem?We have a lot of problem with this issue.

推荐答案

休眠AUTÓ刷新不会为本地SQL查询触发.从5.2开始,这完全取决于您如何引导Hibernate. JPA引导程序将产生JPA行为,该行为将在进行任何查询之前触发刷新,而本机引导程序则不会.

Hibernate AUTÓ flushing does not trigger for native SQL queries. Since 5.2, it all depends on how you bootstrap Hibernate. A JPA bootstrap will yield the JPA behaviour which triggers the flush prior to any query while a native bootstrap will not.

对于较旧的Hibernate版本,即使对于JPA引导程序,它的行为也与传统的刷新模式相同.

For older Hibernate versions, even for JPA bootstraps it behaves as the legacy flush mode.

这篇关于在使用FlushModeType.AUTO进行本机查询之前,JPA不会刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆