views:

254

answers:

1

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.

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.

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?

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.

A: 

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.

Eduardo Scoz