I integrated NH-466 into 1.2GA but still get an error with <join> ('invalid child element'). I included the steps I used for this. Does anyone know the code that I would need to check to see if I have the correct version? Did I perform the steps correctly -- is there any place where I need to include an XSD?
Background: I need to combine table-per-class-hierarchy and table-per-subclass; therefore, I was told that using a <join> in the <subclass> would work (I need to test if both the Get and the Save works properly for this).
DETAILED STEPS FOR INTEGRATING NH-466 to 1.2GA:
1. Create folder, C:\nHibernate
2. Right-click on C:\nHibernate; select 'SVN Checkout' w/ the following settings:
* 'URL of repository':
htps://nhibernate.svn.sourceforge.net/s ... nhibernate
* keep 'HEAD revision' selected
3. Right-click C:\nHibernate, select TortoiseSVN - Merge; When Merge window pops up, make sure the following are set:
* URL"
https://nhibernate.svn.sourceforge.net/ ... nhibernate
* Revision is selected
4. Separately merge each of the following: 2774, 2836, 2953, 2955
5. Open a command window; cd C:\nHibernate; NAnt set-net-2.0-framework-configuration visual-studio
6. From Visual Studio, open C:\RemoteNHibernate\src\NHibernate\NHibernate-2.0.csproj and build it
7. Copied the following from C:\Projects\nHibernate\src\NHibernate\bin\Debug-2.0
Hibernate version: It's a locally built version of 1.2.0.GA merged with the NH-466 patch; see detailed steps that I used for getting 1.2.0GA, merging the 4 SVN revisions for NH-466, building
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
<class name="DomainModel.Device.PhysicalDevice, DomainModel" table="dbo.tblDevice">
<!-- Primary Key -->
<id type="Int32" column="ID" name="ID" unsaved-value="null">
<generator class="identity"></generator>
</id>
<!-- The discriminator tag MUST be just after the <id> tag and before
any <property> tags; otherwise, you'll get an 'invalid child element' XSD validation
error -->
<discriminator column="MyTypeName"/>
<!-- Simple properties -->
<property name="Name" column="DeviceName"/>
<!-- Inheritance: Table per class hierarchy -->
<subclass name="DomainModel.Device.Firewall, DomainModel" discriminator-value="Firewall">
</subclass>
<subclass name="DomainModel.Device.Hub, DomainModel" discriminator-value="Hub">
</subclass>
<subclass name="DomainModel.Device.Router, DomainModel" discriminator-value="Router">
<join table="dbo.tblRouter">
<key column="pDeviceID"/>
<property name="Manufacturer" column="Manufacturer"/>
</join>
</subclass>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Router r = new Router();
rtr.Name = "Rtr1";
rtr.Manufacturer = "Cisco";
session.Save(rtr);
session.Flush();
Full stack trace of any exception that occurs:
NHibernate.MappingException was unhandled by user code
Message="DAL.nHib.MapFiles.PhysicalDevice.hbm.xml(25,8):
XML validation error: The element 'subclass' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'join' in namespace 'urn:nhibernate-mapping-2.2'. List of possible elements expected: 'urn:nhibernate-mapping-2.2:meta urn:nhibernate-mapping-2.2:property urn:nhibernate-mapping-2.2:many-to-one urn:nhibernate-mapping-2.2:one-to-one urn:nhibernate-mapping-2.2:component urn:nhibernate-mapping-2.2:dynamic-component urn:nhibernate-mapping-2.2:any urn:nhibernate-mapping-2.2:map urn:nhibernate-mapping-2.2:set urn:nhibernate-mapping-2.2:list urn:nhibernate-mapping-2.2:bag urn:nhibernate-mapping-2.2:idbag urn:nhibernate-mapping-2.2:array urn:nhibernate-mapping-2.2:primitive-array urn:nhibernate-mapping-2.2:subclass urn:nhibernate-mapping-2.2:loader urn:nhibernate-mapping-2.2:sql-insert urn:nhibernate-mapping-2.2:sql-update urn:nhibernate-mapping-2.2:sql-delete'."
Source="NHibernate"
StackTrace:
at NHibernate.Cfg.Configuration.LogAndThrow(MappingException me) in C:\Projects\nHibernate\src\NHibernate\Cfg\Configuration.cs:line 257
at NHibernate.Cfg.Configuration.ValidationHandler(Object o, ValidationEventArgs args) in C:\Projects\nHibernate\src\NHibernate\Cfg\Configuration.cs:line 1658
at System.Xml.Schema.XmlSchemaValidator.SendValidationEvent(ValidationEventHandler eventHandler, Object sender, XmlSchemaValidationException e, XmlSeverityType severity)
at System.Xml.Schema.XmlSchemaValidator.ElementValidationError(XmlQualifiedName name, ValidationState context,
<I cut out the rest>
Name and version of the database you are using: Microsoft SQL Server 2005; Version: 9.00.1406.00; Product Level: RTM; Edition: Developer Edition
Thanks,
Bill