Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
2.0
Hi everybody,
I have a collection mapped to a column which is not the primary key.
The child class mapping :
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="tsdmodel"
namespace="tsdmodel.engine.entity">
<class name="EntityTimeLineRecord" table="EntityTimeLineRecord">
<id name="Index" column="idx">
<generator class="increment"/>
</id>
<property name="id" column="id" access="field" type="string"/>
<property name="Day0" column="day0"/>
<property name="Day1" column="day1"/>
<property name="Day2" column="day2"/>
<property name="Day3" column="day3"/>
<property name="Day4" column="day4"/>
<property name="Day5" column="day5"/>
<property name="Day6" column="day6"/>
<property name="Label" column="label"/>
<property name="Start" column="start"/>
<property name="Finish" column="finish"/>
<property name="Week" column="week"/>
</class>
</hibernate-mapping>
The parent class mapping :
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="tsdmodel"
namespace="tsdmodel.engine.entity">
<class name="Room" table="Room">
<id name="id" column="rid" access="field">
<generator class="increment">
</generator>
</id>
<property name="Name" column="name"/>
<many-to-one name="RoomType" column="rtid"/>
<many-to-one name="Sector" column="scid"/>
<property name="AcceptExams" column ="acceptexams"/>
<property name="Priority" column="priority"/>
<property name="Size" column="size"/>
<property name ="EntityId" column ="guid" type="String"/>
<bag name="Records" cascade="all" collection-type="obpdlayer.coll.NHCustomCollection`1[[tsdmodel.engine.entity.EntityTimeLineRecord, tsdmodel]], obpdlayer">
<key column="id" property-ref="EntityId"/>
<one-to-many class="EntityTimeLineRecord"/>
</bag>
</class>
The problem is when I insert child records (EntityTimeLineRecords) it works perfectly bu when I try to load instances of type "Room" I got this exception :
Code:
NHibernate.Exceptions.GenericADOException: could not initialize a collection: [tsdmodel.engine.entity.Room.Records#511af0c164bf4253b0880a977610ad79][SQL: SELECT records0_.id as id1_, records0_.idx as idx1_, records0_.idx as idx73_0_, records0_.id as id73_0_, records0_.day0 as day3_73_0_, records0_.day1 as day4_73_0_, records0_.day2 as day5_73_0_, records0_.day3 as day6_73_0_, records0_.day4 as day7_73_0_, records0_.day5 as day8_73_0_, records0_.day6 as day9_73_0_, records0_.label as label73_0_, records0_.start as start73_0_, records0_.finish as finish73_0_, records0_.week as week73_0_ FROM EntityTimeLineRecord records0_ WHERE records0_.id=?] ---> System.ArgumentException: Identifier type mismatch; Found:<System.Int32> Expected:<System.String>
Nom du paramètre : identifier
Likely, it is trying to map an int32 property to a string parameter.
What's wrong with that ?
Best regards