Don't use Native Id Generator with NHibernate

by Scott MIllett 6. February 2011 16:00

I get asked this question a fair bit so I thought I may as well stick it up here so I can refer people to this post in future. If you are using the NHiberante native ID generator — that is, letting your database generate IDs for entities — the database will actually be hit when save is called regardless if you are in a transaction or not. This is because the entity is now part of the unit of work and thus NHibernate needs to give it a valid identity to ensure that any other objects that reference it can be persisted correctly. You can read more about this over on Ayende's blog.

Don't have nightmares



About Me

Hello my name is Scott Millett, this is my blog designed to capture my thoughts on development. You can find out more info on me by checking out my linked in profile below.

View Scott Millett's profile on LinkedIn

Coming soon...


MVP Logo


Month List

Powered by BlogEngine.NET - Eco Theme by n3o Web Designers