I want to (auto)map a base class and its derived class to two different tables, as described here by ayende (unioned subclasses).
however, according to fluent nHibernate's documentation, I don't see a way do do that.
the property in IAutoMappingOverride they refer to is "IsDiscriminated", but that only difrrentiates between table-per-heirarchy and table-per-subclass.
Is it possible that automapping doesn't support unioned subclasses? and if so- can anyone suggest a workaround?
thanks,
Jhonny
Related
I have discovered the method T Generic() in the abstract class ToManyBase<T, TChild, TRelationshipAttributes> but I cannot find any documentation or examples of how this is used, or what it does. Can anyone enlighten me a bit?
Nothing of significance.
It's the equivalent of the NHibernate generic= attribute, which is simply away of explicitly specifying that a collection is a generic one. A holdover from NHibernate's pre-generic days.
i have a custom type that implemented IUserType.
one of my domain classes have a property of this custom type.
now i want to make Automapping work with this domain, it says that "
An association from the table xyz refers to an unmapped class: PersianDate"
PersianDate is my custom type .
how should i tell to automapping that this is not a reference, it is a custom user type that is fitted into a string column !!!
i searched everything that was in the internet , i think there is something wrong here
would you please help me to fix it
i found the answer Here, i should use a UserTypeConvention in Automapping conventions
I'm looking for more information on the extension points within NHibernate.
For instance I know about IUserType and ICacheProvider. However I can't seem to find a good reference of all the different extension points that NHibernate provides?
Is anyone's Google-fu stronger than mine :)
There are no complete references on that... but it's not hard to look at the assembly and find the interfaces and base classes:
IInterceptor
IBatcherFactory
ICollectionTypeFactory
IProxyFactoryFactory
ICacheProvider
IConnectionProvider
ICurrentSessionContext
Dialect
IDriver
IIdentifierGenerator
ITuplizer
And many more...
Take a look at *EventListener (newer mechanism) and IInterceptor (older mechanism, but useful in certain scenarios that EventListeners don't cover). They will get you a long way WRT extending/integrating with NHibernate.
http://www.nhforge.org/doc/nh/en/index.html#events
I have a situation where I have a Common.Domain.Person and Specific.Domain.Person.
First one should be provided as a part of a common package.
Second one appears when common package has to be customized to fit the needs of specific project.
In the object model, it can be easily implemented with inheritance.
In the NH mapping, however, I have encountered a small problem.
I can create an NHibernate <subclass> mapping, but that would require me to use an discriminator. However, I know that if specific person class was inherited, then common class instances will never be used within this specific project.
What is the best way to implement this without adding discriminator column to the base class (since there are no different cases to discriminate)?
this is what i wanted and nhibernate supports it using xml entities. Unfortunately this feature has been borked since (at least) NH v2++.
see also Using Doctype in Nhibernate
A work-around could be to inject these properies programmaticaly when you create the SessionFactory (Dynamic Mapping)
see also http://ayende.com/Blog/archive/2008/05/01/Dynamic-Mapping-with-NHibernate.aspx
Just map the Specific.Domain.Person and leave Common.Domain.Person unmapped.
If you are not saving instances of it, NHibernate does not need to know about it.
What is the current method of implementing the joined-subclass structure with FluentNHibernate? By "current", I mean by not using deprecated methods such as JoinedSubClass or AddPart.
Thanks!
The recommended way to map a joined-subclass is to inherit from SubclassMap much in the same way you inherit from ClassMap for your non-subclass entities.
It's described in the fluent mapping subclasses section on the wiki. For automapping please refer to Automapping Inheritance.