NHibernate SetTimeout on ICriteria

前端 未结 2 1652
挽巷
挽巷 2021-02-18 12:55

Could someone tell me what the units the SetTimeout(int) method in the ICriteria interface uses?
Is it milliseconds, seconds, minutes or other?

相关标签:
2条回答
  • 2021-02-18 13:40

    I think it's seconds. The NHibernate API closely mirrors Hibernate Core for Java, where the Criteria.setTimeout(int) method uses seconds as the units (see also Statement.setQueryTimeout(int)).

    Also, after looking at some NHibernate source, it appears that it's using that value to set the timeout for the underlying ADO.NET query, which uses seconds.

    0 讨论(0)
  • 2021-02-18 13:45

    A little bit of poking around suggests that it could be seconds:

    Assuming that ICriteria is the same as the Criteria interface in Hibernate core, then the JavaDoc for org.hibernate.Criteria provides a hint - the "see also" link to java.sql.Statement.setQueryTimeout(). The latter refers to its timeout parameter as seconds.

    Assuming that the NHibernate implementation follows the implied contract of that method, then that should be fine. However, for peace of mind's sake, I went and looked for some NHibernate specific stuff. There are various references to CommandTimeout; for example, here, related to NHibernate. Sure enough, the documentation for CommandTimeout states that it's seconds.

    I almost didn't post the above, because I don't know the answer outright, and can't find any concrete documentation - but since there is so little on the issue, I figured it couldn't hurt to present these findings.

    0 讨论(0)
提交回复
热议问题