I am not sure if this a problem with my Fluent configuration or some logic in my thinking.
Basically I have a Person class from which I have two inherited classes, Author and Borrower (it's a library system). The mapping I have is.
public class PersonMap : ClassMap<Person>
{
public PersonMap()
{
Id(x => x.Id, "id");
Map(x => x.Name, "name");
// Subclasses
AddPart(new AuthorMap());
AddPart(new BorrowerMap());
}
}
public class AuthorMap : JoinedSubClassPart<Author>
{
public AuthorMap() : base("person_id")
{
Map(x => x.Country, "country");
HasMany(x => x.Books).Cascade.All().WithKeyColumn("book_id");
}
}
public class BorrowerMap : JoinedSubClassPart<Borrower>
{
public BorrowerMap() : base("person_id")
{
Map(x => x.UserName, "user_name");
HasMany(x => x.Schedule).Cascade.SaveUpdate().WithKeyColumn("borrower_id");
}
}
Now if I run the HQL "FROM Author a ORDER BY a.Name" it will return a list of all Author and Borrower entities where I obviously just want a list of authors. Please feel free to set me straight on this.