如何检查 hibernate session 包含的连接是否处于只读模式。
当前正在使用
进行检查Session.connection().isReadOnly()
但是连接已被标记为弃用,是否还有其他方法可以检查它?
最佳答案
您可以在 session 对象上使用 isDefaultReadOnly() 方法。这告诉你,(来自 Hibernate Javadoc)
Will entities and proxies that are loaded into this session be made read-only by default?
此外,您也可以使用 isReadOnly(object) 方法。这会告诉你(再次来自 hibernate javadoc)
Is the specified entity or proxy read-only?
我希望这两者的结合能够满足您的目的。
关于java - 如何在Java中检查hibernate session 连接是否处于只读模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8698740/