Question
Are wrong the mappings or is it a bug?
Hibernate version: 1.0.2
Classes:
Code:
public class Operation
{
private int id;
private PaymentPlan paymentPlan;
//getter and setter
}
public class PaymentPlan
{
private DateTime expirationDate;
private int numberOfPayments;
private IList payments;
//getter and setter
}
public class Payment
{
private int id;
private int amount;
private DateTime expiration;
private PaymentPlan paymentPlan;
//getter and setter
}
Mapping documents:Code:
<?xml version="1.0" encoding="utf-16"?>
<hibernate-mapping xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:nhibernate-mapping-2.0">
<class name="Castle.ActiveRecord.Tests.Model.Nested.Operation, Castle.ActiveRecord.Tests" table="Operation" lazy="false">
<id name="Id" access="property" column="Id" type="Int32" unsaved-value="0">
<generator class="native">
</generator>
</id>
<component name="PaymentPlan">
<property name="ExpirationDate" access="property" column="ExpirationDate" type="System.DateTime" />
<property name="NumberOfPayments" access="property" column="NumberOfPayments" type="Int32" />
<bag name="Payments" access="property" table="Payment" lazy="false">
<key column="PaymentPlan" />
<one-to-many class="Castle.ActiveRecord.Tests.Model.Nested.Payment, Castle.ActiveRecord.Tests" />
</bag>
</component>
</class>
</hibernate-mapping>
and
Code:
<?xml version="1.0" encoding="utf-16"?>
<hibernate-mapping xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:nhibernate-mapping-2.0">
<class name="Castle.ActiveRecord.Tests.Model.Nested.Payment, Castle.ActiveRecord.Tests" table="Payment" lazy="false">
<id name="Id" access="property" column="Id" type="Int32" unsaved-value="0">
<generator class="native">
</generator>
</id>
<property name="Amount" access="property" column="Amount" type="Int32" />
<property name="Expiration" access="property" column="Expiration" type="System.DateTime" />
<many-to-one name="PaymentPlan" access="property" class="Castle.ActiveRecord.Tests.Model.Nested.PaymentPlan, Castle.ActiveRecord.Tests" column="PaymentPlan" />
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:Code:
TestCase 'Castle.ActiveRecord.Tests.JoinedSubClassWithNestedClassTestCase.Operations' failed: System.NullReferenceException : Object reference not set to an instance of an object.
at NHibernate.Cfg.Mapping.GetIdentifierType(Type persistentClass)
at NHibernate.Type.ManyToOneType.GetReferencedType(IMapping mapping)
at NHibernate.Type.ManyToOneType.GetColumnSpan(IMapping mapping)
at NHibernate.Mapping.SimpleValue.IsValid(IMapping mapping)
at NHibernate.Mapping.Property.IsValid(IMapping mapping)
at NHibernate.Mapping.PersistentClass.Validate(IMapping mapping)
at NHibernate.Mapping.RootClass.Validate(IMapping mapping)
at NHibernate.Cfg.Configuration.Validate()
at NHibernate.Cfg.Configuration.BuildSessionFactory()
D:\Progetti\Castle\ActiveRecord\Castle.ActiveRecord\Framework\SessionFactoryHolder.cs(115,0): at Castle.ActiveRecord.Framework.SessionFactoryHolder.GetSessionFactory(Type type)
D:\Progetti\Castle\ActiveRecord\Castle.ActiveRecord\Framework\SessionFactoryHolder.cs(140,0): at Castle.ActiveRecord.Framework.SessionFactoryHolder.CreateSession(Type type)
d:\progetti\castle\activerecord\castle.activerecord\framework\activerecordbase.cs(178,0): at Castle.ActiveRecord.ActiveRecordBase.DeleteAll(Type type)
d:\progetti\castle\activerecord\castle.activerecord.tests\model\nested\operation.cs(31,0): at Castle.ActiveRecord.Tests.Model.Nested.Operation.DeleteAll()
d:\progetti\castle\activerecord\castle.activerecord.tests\nestedclasswithbelongstotestcase.cs(24,0): at Castle.ActiveRecord.Tests.JoinedSubClassWithNestedClassTestCase.Operations()
Name and version of the database you are using:
MSSql 2000
Thank you!
Antonio.