Hey guys,
I'm just switching over all my hbm files to NHM attributes since maintaining one instead of two files is much easier. Furthermore, I often can use typeof which simplifies things in case of refactorings.
So here is an issue that I ran into: With NHMA Property attributes I can neglect the Name parameter and NHMA will automatically generate the correct XML name attribute.
I tried to do the same thing with NHMA Id attributes, neglecting the Name parameter, NHMA won't generate the XML name attribute. One of the effects is that the ID property of my objects doesn't get populated.
I looked into the code and found the two methods WriteId and WriteProperty that generate the Mapping XML. WriteProperty writes a name attribute in every case and uses reflection if its not specified. WriteId only writes the name attribute if it's really specified.
I checked the NHibernate documentation and it states that name for id is optional whereas name for properties is mandatory. So, it seems NHMA is in line with the NHibernate specification.
What I'm wondering is in what cases would I specify an ID but not give it a name. As I said, the property in NHibernate didn't get populated so where's the point? Will NHibernate internally store the ID so that it's never exposed or what?
Thanks, Christoph
|