-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Unknown entity class if it's <subclass> of <joined-
PostPosted: Sat Dec 29, 2007 7:29 pm 
Regular
Regular

Joined: Thu Nov 30, 2006 10:48 am
Posts: 59
Problem: nHibernate can't find the entity class when it appears as a <subclass> of a <joined-subclass>

Exception: "Unknown entity class: Domain.Unit"

Description (you can skip this and go directly to the class map file and other info that appears after this): I have an inheritance hierarchy where an abstract class, AbstractUnit, implements an interface, IDeviceContainer. The IDeviceContainer interface (and those classes that implement it such as AbstractUnit) has a table-per-subclass inheritance implementation (tblDeviceContainer is for the interface, tblUnit is for all Units & it has a foreign key to tblDeviceContainer, and tblNode is for Nodes & it has a foreign key to tblDeviceContainer).

AbstractUnit is itself an inheritance hierarchy with concrete subclasses, Unit and UnitSection. This inheritance implementation is implemented with a table-per-class-hierarchy (tblUnit has both Unit and UnitSection). The AbstractUnit is a <joined-subclass> of the class mapping, IDeviceContainer. Unit and UnitSection are <subclass>es under AbstractUnit's <joined-subclass> element.

Domain Object Model:

I have a class hierarchy as follows:
+ EDomain (abstract base class)
+ + AbstractUnit (abstract base class), implements IDeviceContainer
+ + + Unit (concrete subclass of AbstractUnit)
+ + + UnitSection (concrete subclass of AbstractUnit)

C# classes/interfaces:

Domain/object model (all are in the namespace, Domain):
public interface IDeviceContainer { ... }
public abstract class EDomain { ... }

public class AbstractUnit : EDomain, IDeviceContainer { ... }
public class Unit : AbstractUnit { ... }
public class UnitSection : AbstractUnit { ... }

Code between sessionFactory.openSession() and session.close():

Unit unit = new Unit();
...
session.Save(unit);



Mapping documents:

<class name="Domain.IDeviceContainer, Domain" table="dbo.tblDeviceContainer">

<joined-subclass name="Domain.Node, Domain" table="tblNode">
<key column="FK_pDeviceContainerID"/>
</joined-subclass>

<joined-subclass name="Domain.AbstractUnit, Domain" table="tblUnit">
<key column="FK_pDeviceContainerID"/>

<subclass name="Domain.Unit, Domain" discriminator-value="Unit">
</subclass>

<subclass name="Domain.UnitSection, Domain" discriminator-value="UnitSection">
</subclass>

</joined-subclass>

</class>
</hibernate-mapping>

_________________
metazone


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 31, 2007 4:10 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
I didn't think mixing joined-subclass and subclass was supported. You may want to confirm that.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.