I have now adapted my mapping files and classes (made all accessors virtual and implemented inverse=true on one side of bi-directional relations). Now I am getting an even harder to debug error message. It seems to be about a many-to-one relationship of which I have none in my mappingfiles??
Hibernate version:
1.0.2.0
Mapping documents:
Groep.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"
namespace="Symtech.Verzuiminzicht.BO" assembly="Symtech.Verzuiminzicht.BO">
<class name="Groep" table="Groep">
<id name="ID" type="Int32" access="nosetter">
<column name="ID" not-null="true"/>
<generator class="native" />
</id>
<property name="Naam" type="String" column="Naam" not-null="true"/>
<bag name="Personen" table="Gebruiker_Groep" cascade="all" lazy="true" inverse="true">
<key column="GroepID"/>
<many-to-many column="GebruikerID" class="Persoon"/>
</bag>
</class>
</hibernate-mapping>
Persoon.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"
namespace="Symtech.Verzuiminzicht.BO" assembly="Symtech.Verzuiminzicht.BO">
<class name="Persoon" table="Persoon">
<id name="ID" type="Int32" access="nosetter">
<column name="ID" not-null="true"/>
<generator class="native" />
</id>
<property name="Achternaam" type="String" column="Achternaam" not-null="true"/>
<joined-subclass name="Gebruiker" table="Gebruiker" lazy="true">
<key column="PersoonID"/>
<property name="Naam" type="String" column="Naam" not-null="true"/>
<property name="Wachtwoord" type="String" column="Wachtwoord" not-null="true"/>
<property name="Email" type="String" column="Email" not-null="true"/>
<bag name="Groep" table="Gebruiker_Groep" cascade="all" lazy="true">
<key column="GebruikerID"/>
<many-to-many column="GroepID" class="Groep"/>
</bag>
</joined-subclass>
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:Code:
System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Source="NHibernate"
StackTrace:
at NHibernate.Cfg.Configuration.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.Collection.Validate(IMapping mapping)
at NHibernate.Cfg.Configuration.Validate()
at NHibernate.Cfg.Configuration.BuildSessionFactory()
at Symtech.Verzuiminzicht.DA.NHibernateHttpModule.CreateSessionFactory() in D:\projecten\verzuiminzicht\VI_Business\Symtech.Verzuiminzicht.Factories\NHibernateHttpModule.cs:line 84
at Symtech.Verzuiminzicht.DA.NHibernateHttpModule.get_CurrentFactory() in D:\projecten\verzuiminzicht\VI_Business\Symtech.Verzuiminzicht.Factories\NHibernateHttpModule.cs:line 125
at Symtech.Verzuiminzicht.DA.NHibernateHttpModule.CreateSession() in D:\projecten\verzuiminzicht\VI_Business\Symtech.Verzuiminzicht.Factories\NHibernateHttpModule.cs:line 139
at Symtech.Verzuiminzicht.DA.NHibernateHttpModule.get_CurrentSession() in D:\projecten\verzuiminzicht\VI_Business\Symtech.Verzuiminzicht.Factories\NHibernateHttpModule.cs:line 186
at Symtech.Verzuiminzicht.DA.GebruikerFactory.Save(Gebruiker gebr) in D:\projecten\verzuiminzicht\VI_Business\Symtech.Verzuiminzicht.Factories\GebruikerFactory.cs:line 13
at Default2.butOpslaan_Click(Object sender, EventArgs e) in d:\projecten\verzuiminzicht\website\Install.aspx.cs:line 77
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Name and version of the database you are using:
MS SQL Server Express 2005 (9.0.1399)