强制 Hibernate 不使用 sp_execute 进行非查询
有没有办法强制 Hibernate 不使用 sp_execute?
考虑这段代码,
String queryString = "SET DEADLOCK_PRIORITY LOW;";
SQLQuery query = session.createSQLQuery(queryString);
return query.executeUpdate();
它变成了sp_prepare,然后是sp_execute,这违背了目的:执行此语句后,会话死锁优先级恢复为NORMAL。
在.NET中,以下代码将执行直接声明并且会话的优先级保持低(根据需要)
command = new SqlCommand("SET DEADLOCK_PRIORITY LOW", _Connection);
command.ExecuteNonQuery();
如何强制 Hibernate 以相同的方式发送声明?
Is there a way to force Hibernate not to use sp_execute?
Consider this code
String queryString = "SET DEADLOCK_PRIORITY LOW;";
SQLQuery query = session.createSQLQuery(queryString);
return query.executeUpdate();
It turns into sp_prepare, then sp_execute and that defeats the purpose: after executing this statement session deadlock priority is back to NORMAL
In .NET the following code would execute the statement directly and priority for the session stays LOW (as desired)
command = new SqlCommand("SET DEADLOCK_PRIORITY LOW", _Connection);
command.ExecuteNonQuery();
How to force Hibernate to send the statement in the same manner?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了一种方法来实现这一点。
但是,connection() 已“已弃用并计划在 Hibernate 4.x 中删除”(已讨论 这里)
I found a way to accomplish that.
However, connection() is "deprecated and scheduled for removal in Hibernate 4.x" (discussed here)