|
From: NHibernate J. <mik...@us...> - 2006-10-26 11:55:32
|
abstract class not recognized using multiple mapping files
----------------------------------------------------------
Key: NH-779
URL: http://jira.nhibernate.org/browse/NH-779
Project: NHibernate
Type: Bug
Versions: 1.0.2
Reporter: Hace
When an abstract class and (one or more) joined-subclasses are not in one mapping file, but joined-subclasses are in separate mappingfiles, the connection between the abstract class and the joined subclasses is lost. An error of 'cannot instantiate abstract class' occurs.
[ AbstractClass.hbm.xml ]
<hibernate-mapping>
<class name="Namespace.Common.AbstractClass, Namespace.Common" table="GeneralItem">
<id name="GeneralItemId" type="Int32" column="GeneralItemId" >
<generator class="identity"/>
</id>
<property name="GeneralText" column="GeneralText" />
<joined-subclass name="Namespace.Common.A.ConcreteClassA, Namespace.Common.A" table="ItemsA" extends="Namespace.Common.AbstractClass, Namespace.Common">
<key column="GeneralItemId" />
..concrete properties for A..
</joined-subclass>
</class>
</hibernate-mapping>
[ ConcreteClassB.hbm.xml ]
<hibernate-mapping>
<joined-subclass name="Namespace.Common.B.ConcreteClassB, Namespace.Common.B" table="ItemsB" extends="Namespace.Common.AbstractClass, Namespace.Common">
<key column="GeneralItemId" />
..concrete properties for B..
</joined-subclass>
</hibernate-mapping>
Items for ConcreteClassB will not be loaded correctly, only because the joined-subclass is not in the SAME mappingfile as ConcreteClassA ?
[ Code ]
List<AbstractClass> itemList = new List<AbstractClass>();
ISession session = OurSession.CurrentSession;
ICriteria NHibernateCriteria = session.CreateCriteria(typeof(AbstractClass));
NHibernateCriteria.Add(Expression.In("GeneralItemId", generalItemIds.ToArray()));
try
{
IEnumerable<AbstractClass> enumerable = (AbstractClass[])ArrayList.Adapter(NHibernateCriteria.List()).ToArray(typeof(AbstractClass));
itemList = new List<AbstractClass>(enumerable);
}
catch(Exception exception)
{
... log exception..
}
......
dostuff
foreach(ConcreteClassA in itemList)
....
[ /code ]
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.nhibernate.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
|