GeneratedBy.Increment() 在单个 SessionFactory 中是线程安全的吗?

Is GeneratedBy.Increment() thread-safe within a single SessionFactory?

我的应用程序使用

Id(x => x.Id).GeneratedBy.Increment();

用于生成主键。我读过一些关于 Increment 的文章,现在我很担心:所有这些文章都说 Increment 集群 中使用时是危险的。但是,没有集群,它是一个具有单个 SessionFactory 实例的普通 Web 应用程序。但是,存在并发线程,它们都共享相同的 SessionFactory.

我应该担心吗?什么对象为新创建的实例提供主键值?是线程安全的 SessionFactory 还是不安全的 Session

查看 source, the Generate() method of the IncrementGenerator class is decorated with the MethodImpl attribute and the MethodImplOptions.Synchronized option. This suggests 对方法的访问是同步的,因此是线程安全的。