I'm trying to set up the mapping for a couple of classes. The one class has a Dictionary<Guid, Factor> to hold a collection of factors. However, I seem to be getting some issues with the mapping for the Guideline. The issue seems to be the <map> tag as if I comment it out everything works fine. I am accessing the dictionary of factors through the field.
The mapping for the Factor is fine as that works on its own, so therefore it has to be in the <map> tag for the guideline.
Any help is appriciated.
Hibernate version: NHibernate 1.2 Alpha1
Mapping documents: <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"> <class name="amec.ee.sage.domain.gs.Guideline, Sage.Domain" table="GS.GUIDELINES" lazy="false"> <id name="GuidelineID" column="GUIDELINE_ID" type="System.Int32" unsaved-value="0"> <generator class="identity" /> </id> <property name="Author" column="AUTHOR" type="System.String" not-null="true" length="50" unique="false" /> <property name="Date" column="DATE" type="System.DateTime" not-null="true" unique="false" /> <property name="IsRegulated" column="IS_REGULATED" type="System.Boolean" not-null="true" unique="false" /> <property name="Title" column="TITLE" type="System.String" not-null="true" length="200" unique="false" /> <property name="RowGuid" column="ROWGUID" type="System.Guid" not-null="true" unique="true" /> <map name="factors" table="GS.FACTORS" inverse="false" cascade="none" sort="unsorted" lazy="false" access="field"> <key column="GUIDELINE_ID"/> <index column="ROWGUID" type="System.Guid" /> <one-to-many class="amec.ee.sage.domain.gs.Factor, Sage.Domain" /> </map> </class>
<class name="amec.ee.sage.domain.gs.Factor, Sage.Domain" table="GS.FACTORS" lazy="false" > <id name="FactorID" column="FACTOR_ID" type="System.Int32" unsaved-value="0" access="property"> <generator class="identity"/> </id> <property name="TimeStamp" column="VERSION" type="System.Byte[]" not-null="true" unique="true"/> <property name="Name" column="NAME" type="System.String" length="100" not-null="true" unique="false" /> <property name="Description" column="DESCRIPTION" type="System.String" length="1000" not-null="false" unique="false" /> <property name="Value" column="VALUE" type="System.String" length="150" not-null="true" unique="false" /> <property name="RowGuid" column="ROWGUID" type="System.Guid" not-null="false" unique="true" access="property"/> <component name="Type" class="amec.ee.sage.domain.gs.FactorType, Sage.Domain" insert="false" update="false"> <property name="TypeID" column="TYPE_ID" type="System.String" length="5" not-null="true" unique ="true" /> <property name="Name" column="NAME" type="System.String" length="35" not-null="true" unique="true" /> <property name="Description" column="DESCRIPTION" type="System.String" length="250" not-null="false" unique="false" /> </component> </class>
Tables: GS.GUIDELINES pk GUIDELINE_ID ...
GS.FACTORS pk FACTOR_ID fk GUIDELINE_ID ... [b]
[b]Code between sessionFactory.openSession() and session.close(): session.Load<Guideline>(1)
Full stack trace of any exception that occurs: NHibernate.MappingException: Invalid mapping information specified for type amec.ee.sage.domain.gs.Guideline, check your mapping file for property type mismatches
at NHibernate.Persister.Entity.AbstractEntityPersister.SetPropertyValues(Object obj, Object[] values) in J:\EDMGProjects\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs:line 204 at NHibernate.Impl.SessionImpl.InitializeEntity(Object obj) in J:\EDMGProjects\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Impl\SessionImpl.cs:line 2844 at NHibernate.Loader.Loader.InitializeEntitiesAndCollections(IList hydratedObjects, Object resultSetId, ISessionImplementor session) in J:\EDMGProjects\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Loader\Loader.cs:line 518 at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) in J:\EDMGProjects\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Loader\Loader.cs:line 453 at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) in J:\EDMGProjects\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Loader\Loader.cs:line 182 at NHibernate.Loader.Loader.LoadEntity(ISessionImplementor session, Object id, IType identifierType, Object optionalObject, Type optionalEntityName, Object optionalIdentifier, IEntityPersister persister) in J:\EDMGProjects\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Loader\Loader.cs:line 1405 at NHibernate.Loader.Entity.AbstractEntityLoader.Load(ISessionImplementor session, Object id, Object optionalObject, Object optionalId) in J:\EDMGProjects\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Loader\Entity\AbstractEntityLoader.cs:line 46 at NHibernate.Loader.Entity.AbstractEntityLoader.Load(Object id, Object optionalObject, ISessionImplementor session) in J:\EDMGProjects\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Loader\Entity\AbstractEntityLoader.cs:line 41 at NHibernate.Persister.Entity.AbstractEntityPersister.Load(Object id, Object optionalObject, LockMode lockMode, ISessionImplementor session) in J:\EDMGProjects\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs:line 2055 at NHibernate.Impl.SessionImpl.DoLoad(Type theClass, Object id, Object optionalObject, LockMode lockMode, Boolean checkDeleted) in J:\EDMGProjects\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Impl\SessionImpl.cs:line 2700 at NHibernate.Impl.SessionImpl.DoLoadByClass(Type clazz, Object id, Boolean checkDeleted, Boolean allowProxyCreation) in J:\EDMGProjects\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Impl\SessionImpl.cs:line 2469 at NHibernate.Impl.SessionImpl.Load(Type clazz, Object id) in J:\EDMGProjects\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Impl\SessionImpl.cs:line 2337 at NHibernate.Impl.SessionImpl.Load[T](Object id) in J:\EDMGProjects\NHibernate-1.2.0.Alpha1-debug\src\NHibernate\Impl\SessionImpl.cs:line 2345 at amec.ee.sage.persistence.nhbr.NHibernateDao`1.get(Int32 id) in NHibernateDao.cs:line 148 at amec.ee.sage.persistence.test.nhbr.gs.TestGuidelineDao.testGetByID() in TestGuidelineDao.cs:line 25 [b]
[b]Name and version of the database you are using: Sql2005
The generated SQL (show_sql=true): NHibernate: SELECT guideline0_.GUIDELINE_ID as GUIDELINE1_0_, guideline0_.TITLE as TITLE2_0_, guideline0_.AUTHOR as AUTHOR2_0_, guideline0_.IS_REGULATED as IS4_2_0_, guideline0_.DATE as DATE2_0_, guideline0_.ROWGUID as ROWGUID2_0_ FROM GS.GUIDELINES guideline0_ WHERE guideline0_.GUIDELINE_ID=@p0 @p0 = '2'
Debug level Hibernate log excerpt:
|