Hello,
This question was posted on StackOverflow <goog_632167627>, but expanding
on it here. I'm having trouble understanding NHibernate behaviour when
mapping subclasses, and would like to ask you for help as I cannot
determine if what I'm seeing is misconfiguration on my part or a bug - with
my limited knowledge of mapping by code and NHibernate
We're loosely following DDD principles, and have a simple base class for
all of our aggregate roots (main business objects). This base class has no
meaning of itself, and therefore is declared abstract and is not mapped.
Only the inheriting specific classes are mapped, also mapping properties
inherited from the base abstract class.
A problem arises when we try to combine an inherited property with a
property declared on the concrete class into a composed id like so:
public class BaseClass
{
public int InheritedId { get; set; }
}
public class Subclass : BaseClass
{
public int OwnId { get; set; }
}
public class SubclassMap : ClassMapping<Subclass>
{
public SubclassMap()
{
Table("Subclass");
ComposedId(x => {
x.Property(p => p.InheritedId);
x.Property(p => p.OwnId);
});
}
}
Given the above mapping, explicit model mapper only maps OwnId to be the
primary key of the table, skipping on the InheritedId. As I said before, it
may be a bug (as suggested on StackOverflow) or perhaps NHibernate needs
some clear instructions that I'm trying to use implicit polymorphism? If it
is the latter, how do I do that with Loquacious?
Kind regards,
Dawid Ciecierski
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/nhusers/-/myDnPNC1ygkJ.
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.