Hello I've got a better grip on when to use a custom type thanks to (http:// nhforge.org/doc/nh/en/index.html#mapping-types), below. Still hoping for some guidance on the first two questions.
Cheers, Berryl "Even though NHibernate's rich range of built-in types and support for components means you will very rarely need to use a custom type, it is nevertheless considered good form to use custom types for (non-entity) classes that occur frequently in your application. For example, a MonetaryAmount class is a good candidate for an ICompositeUserType, even though it could easily be mapped as a component. One motivation for this is abstraction. With a custom type, your mapping documents would be future-proofed against possible changes in your way of representing monetary values." On May 20, 1:14 pm, Berryl Hesh <[email protected]> wrote: > I have an interface property (ITimesheetActivity) on a class that I've > mapped as a component. I haven't fleshed this out much so I mocked a > stub with Rhino (and set an Id) and tried to save it, getting the > exception. > > Questions > 1). should I be able to persist a mocked object? > 2). the column is being treated as a string with length 50, although > the type is correctly Int32. Maybe a misuse of FNH conventions but it > can't be helping. > 3). is there a quick answer or link that explains when to use a > userType instead of a component? Is there a better way to use > ITimesheetActivity in my object model and persist it with just an Id? > > HBM mapping: > > <component name="Activity" insert="true" update="true"> > <property name="Id" type="Int32"> > <column name="ActivityId" not-null="true" unique="true" > length="50" /> > </property> > </component> > > FNH mapping: > > mapping.Component(x => x.Activity, c => > c.Map(x => x.Id, "ActivityId").Not.Nullable > ().Unique()); > > TIA, > Berryl --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" 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/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
