I worked a little on this and didn’t understand anything. Is it possible to create a Hibernate query to return a discriminator based set of objects?
I have an AbstractUser class that is extended by the specific classes UserTypeA and UserTypeB. I use the table-per-hierarchy model to map my classes in NHibernate, so UserTypeA and UserTypeB are stored in the same table with different discriminator values. Here is my discriminator display property:
<discriminator column="Type" type="string"/>
I have a column in my table that contains the name of the user type. I am wondering if it is possible to run an NHibernate query using this.
I tried this:
public IList<DomainBase> FindByType(string typeName, Type type)
{
string query = "from " + type.Name + " k where k.Type = " + typeName;
return Session.CreateQuery(query).List<DomainBase>();
}
Type , , . , , ?