views:

116

answers:

1

I'm creating a blog library using nHibernate and I have a BlogEntry class that has a CreatedBy property of type User (User is an abstract class). The two concrete implementations of the User class are RegisteredUser and UnknownUser. I'd like nHibernate to instantiate UnknownUser class if the value in the CreatedBy field is null. If it is not null I'd like it to instantiate RegisteredUser.

Is this possible with nHibernate? and what should my mapping file look like if it is?

A: 

I actually figured it out. I watched the video here on modeling inheritance in nHibernate. I needed to create subclass nodes in my User mapping file and create a discriminator column in the table.

Chris