ORM theory and practices are not horrified by natural-keys but by the usage of natural-keys as POID (Persistent Object-ID).We are supporting composite-id only for legacy DB, the usage of business-meaning values for PK is strongly discouraged.
2009/8/8 Sean Foy <[email protected]> > > I'd like some feedback on a possible contribution: an interceptor that > classifies entities as transient or dirty. > > NHibernate already classifies entities using unsaved-value, but that > doesn't work so well with natural keys, where the key value is > meaningful/significant even before the entity has been stored for the > first time. It seems common to write a small method to wrap the > NHibernate primitives in order to explicitly insert or update at the > right times. > > Usually, though, I want newly instantiated objects to transient and > objects that NHibernate has seen before to be considered persistent. > Rather than adorning each entity with a boolean flag plus code to > maintain that flag and invoke the appropriate NH primitive when I want > to write the entity to the database, I wrote an interceptor. > > The interceptor maps entities to booleans and advises NH about the > transient/persistent status at the appropriate times. It uses weak > references to avoid prolonging the GC-lifetimes of entities. > > I'm expecting that some NH expert will be horrified by my general idea > here. I'm an NH neophyte so it seems likely that someone will point > out something I've overlooked. On the other hand, it seems that NH > culture is pretty dismissive of natural keys; maybe what's been > overlooked (out of a lack of interest) is support for the use of > natural keys in NH. I'm posting here so that either I'll learn > something about NH, or NH will get stronger as a result of my > contribution. > > So, what do you think? > > > > -- Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "NHibernate Contrib - Development Group" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com.ar/group/nhcdevs?hl=en -~----------~----~----~----~------~----~------~--~---
