views:

830

answers:

1

When I configure my application to use HiLo Id generation, I see one round-trip per row inserted in the database. All the documentation I've read has indicated that I should see far fewer round-trips.

My objects are all generally configured (fluently) as such:

Id(t=>t.Id).GeneratedBy.HiLo("MyObject_Identity","MaxId","1000");

Additionally my batch size is set to 75 on the connection.

I know I'm probably doing something relatively stupid.

+1  A: 

Do you mean you are seeing a round trip for each insert to go get a new high value for the ID? If so are you using a new instance of the SessionFactory on each operation? The SessionFactory is responsible for managing the retrieval of the high value. Typically you should only have one SessionFactory per application instance (via singleton or IoC container).

Daniel Auger
Yes. Within a single session factory (actually a single session) I was seeing a single round-trip per instance save. I have since reverted the application to using identity. which I know is an anti-pattern with nhibernate, but it works. I later noticed that there was a batch size property at the object level. I figure I have something configured wrong.
JeffreyABecker