NHibernate的批量插入不与协会工作? [英] nHibernate batch insert doesn't work with associations?

查看:156
本文介绍了NHibernate的批量插入不与协会工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到有关NHibernate的如何决定如何批处理多个插入在一起的更多信息。如果你有相同类型的对象的简单列表显然,它只是工作,无子女的对象。

I'm trying to find more information about how nHibernate decides how to batch multiple inserts together. Apparently it just works if you have a simple list of objects of the same type, with no children objects.

在我的申请,我有三个表A,B和C之间的一个一对多的关系:一个拥有许多B,B有我使用A的ID的本地发电机C.很多,但对B和C我只是用复合键,这是在code分配,这样NHibernate的只能做插入。这些似乎要被罚款的工作,我可以得到所有的对象正确保存。

In my application, I have a one-to-many relation between three tables A, B, and C: A has many B, B has many C. I'm using a native generator for A's Id, but for B and C I'm just using composite-keys, which are assigned in the code, so that nHibernate can only do inserts. These seem to be working fine, and I can get all the objects saved properly.

问题是,NHibernate的似乎并不足够聪明,尽量先插入A类的所有对象批量,然后在所有批次B和批次最后所有的C。现在,它试图批次C型的唯一目的,如果有多个

The problem is that nHibernate doesn't seem to be smart enough to try to first insert all objects of type A in batch, then all B in batch, and finally all C in batch. Right now, it tries to batch only the objects of type C, if there are multiple.

这听起来是否正确?有什么办法改变这种行为?

Does this sound correct? Is there any way to change this behavior?

我的应用程序需要同时添加数百种A,B和C的对象,而不必做逐一是一个很大的性能问题。

My application needs to add hundreds of objects of types A,B and C at the same time, and having to do one by one is a big performance problem.

推荐答案

在情况下,有谁需要帮忙,NHibernate的,的确可以在不同的树的不批插入的对象。在我的应用程序,我结束了修改对象结构,使NHibernate的快乐。

In case anyone ever needs any help, nHibernate indeed cannot batch insert objects in different trees. In my application, I ended up modifying the object structure to make nHibernate happy.

这篇关于NHibernate的批量插入不与协会工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆