【问题标题】:In nhibernate, when I commit my transaction, the sql update statements don't show in the console. Why?在 nhibernate 中,当我提交事务时,sql update 语句不会显示在控制台中。为什么?
【发布时间】:2011-10-31 18:15:56
【问题描述】:

当我提交事务时,更新语句没有显示在我的 nhibernate 应用程序的控制台中,这让我有点恼火。

我在配置文件中使用了 show_sql = true。据我所知,所有的选择语句都在显示。当我不使用事务时也会显示更新。

以前有人遇到过这种情况吗?我该如何解决?

谢谢!

【问题讨论】:

  • 听起来很奇怪。你在用FlushMode.Commit吗?更新是否已执行,但它只是没有显示在输出(调试)窗口中?
  • FlushMode.Never 实际上。是的,更新显示在 sql 分析器中,而不是输出窗口。
  • 可以批量更新。您是否只看到一些更新而不是全部?
  • 我只看到不通过事务类的更新

标签: nhibernate


【解决方案1】:

答案在这里NHibernate not showing Update queries with ShowSql enabled

只需使用此配置:

<property name="adonet.batch_size">0</property>

【讨论】:

  • 这开始为我显示 INSERT、UPDATE 和 DELETE。谢谢!
【解决方案2】:

使用流畅的 NHibernate,

Fluently.Configure().Database(MsSqlConfiguration
    .MsSql2012
    .ConnectionString(MsSqlDbConnectionString);
    .ShowSql()
    .AdoNetBatchSize(0) // <== to show UPDATE statements
    // etc.
    );

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-10
    • 1970-01-01
    相关资源
    最近更新 更多