From: NHibernate J. <mik...@us...> - 2006-11-06 14:41:29
|
[ http://jira.nhibernate.org/browse/NH-779?page=all ] Sergey Koshcheyev closed NH-779: -------------------------------- Fix Version: (was: 1.2.0.Beta2) Resolution: Fixed Seems to work for me using the SVN version, so I'm assuming it was fixed some time ago. > abstract class not recognized using multiple mapping files > ---------------------------------------------------------- > > Key: NH-779 > URL: http://jira.nhibernate.org/browse/NH-779 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.0.2 > Reporter: Hace > Attachments: JoinedSubClass.zip > > 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 |