在休眠状态下设置 allowOutOfTransactionUpdateOperations 属性

Setting allowOutOfTransactionUpdateOperations property in hibernate

我正在使用 Hibernate 5.2,只是想检查 AvailableSettings 中是否有配置 属性,我可以使用它来设置 allowOutOfTransactionUpdateOperations 在构建 sessionFactory 时为真。通过查看代码,可以使用 sessionFactoryBuilder.allowOutOfTransactionUpdateOperations(true); 进行设置;但问题是我们只能在 Configuration class.

中获取 sessionFactoryBuilder 的引用

我试过参考 https://docs.jboss.org/hibernate/orm/5.2/javadocs/org/hibernate/boot/SessionFactoryBuilder.html#allowOutOfTransactionUpdateOperations-boolean-

但它没有提及 AvailableSettings 是否可用。

有没有人尝试过在构建 sessionFactory 时使用元数据或其他方式设置此 属性?

请具体回答 hibernate 5.2。

我刚刚从以下休眠论坛中得到了这个问题的回答 post https://forum.hibernate.org/viewtopic.php?f=1&t=1044395

我们可以使用如下设置hibernate.allow_update_outside_transaction 设置值。