NHibernate version:2.0.1 GA
Hi,
I have these classes and xml files.
public abstract class AbstractClass1
{
private int _id;
private string _info;
public virtual int Id
{
get { return _id; }
set { _id = value; }
}
public virtual string Info
{
get { return _info; }
set { _info = value; }
}
}
<class name="AbstractClass1" abstract="true" table="AbstractClass1" discriminator-value="0">
<id name="Id" type="int" unsaved-value="-1">
<generator class="identity"/>
</id>
<discriminator column="TypeAbstractClass1" type="byte" />
<property name="Info" type="string"/>
<subclass name="ExtendedAbstractClass1_1" discriminator-value="1">
<join table="ExtendedAbstractClass1_1">
<key column="Id_AbstractClass1"/>
...
</join>
</subclass>
<subclass name="ExtendedAbstractClass1_2" discriminator-value="2">
</subclass>
</class>
public abstract class AbstractClass2<TAbstract> where TAbstract : AbstractClass1
{
private int _id;
private TAbstract _abstract;
public virtual int Id
{
get { return _id; }
set { _id = value; }
}
public virtual TAbstract AbstractClass1
{
get{return _abstract;}
set{_abstract = value;}
}
}
public class ExtendedAbstractClass2_1 : AbstractClass2<ExtendedAbstractClass1_1>
{
...
...
}
<class name="AbstractClass2" abstract="true" table="AbstractClass_2" discriminator-value="0">
<id name="Id" type="int" unsaved-value="-1">
<generator class="identity"/>
</id>
<discriminator column="TypeAbstractClass2" type="byte" />
<many-to-one name="AbstractClass1"
column="Id_AbstractClass1"
not-null="true"
fetch="select"/>
<subclass name="ExtendedAbstractClass2_1" discriminator-value="1">
<join table="ExtendedAbstractClass2_1">
<key column="Id_AbstractClass1"/>
<property name="..." type="string"/>
<property name="..." type="string"/>
</join>
</subclass>
<subclass name="ExtendedAbstractClass2_2" discriminator-value="2">
</subclass>
</class>
I know the naming might be confusing, sorry for that.
I get and error on the build of "AbstractClass2".hbm.xml file saying that it can't load type "AbstractClass2".
This works if I dont't make AbstractClass2 generic.
I would like to get a strongly typed object of type AbstractClass1 in the ExtendedAbstractClasses from AbstractClass2. Is this possible? Is this the right approach?
Any help would be appreciated.
|