什么FlushModeType使用spring的@Transactional?

时间:2017-04-03 15:41:22

标签: spring hibernate jpa spring-transactions

我理解,当直接使用会话时,hibernate的默认FlushModeAUTO

当使用Spring的FlushMode代替时,我无法弄清楚@Transactional类型是什么。我的猜测是COMMIT因为它没有意义,否则因为@Transactional意味着在带注释的方法退出时提交事务。

有人可以提供建议吗?

参考源代码或官方文档会很棒......

1 个答案:

答案 0 :(得分:1)

Spring不会更改默认配置,因此它是<h:form> <p:panel id="panel"> <p:messages id="msgs"/> <p:outputLabel for="watchNoticeId" value="#{msg.rfeWatchNoticeId}" /> <h:panelGrid columns="2" cellpadding="5"> <p:inputText id="watchNoticeId" value="#{watchNotice.id}" size="20" style="vertical-align: top;" disabled="#{! raudUserSessionBean.raudUser.referMode}"> <p:ajax event="change" process="@this" /> <f:validateLength maximum="18" update="panel" /> </p:inputText> <p:message for="watchNoticeId" display="icon" /> </h:panelGrid> <p:commandButton value="Validate" update="panel" icon="ui-icon-check" /> </p:panel> </h:form>

刷新模式会影响何时将持久性上下文的更改写入数据库,提交这些更改是另一回事,并在事务结束时发生(无论何时在提交之前将更改刷新到db)