Try reversing the order of Hospital_Id and Patient_Id in the key
definition of your set to match how you have them in your composite-id
definition.

On Mon, May 2, 2011 at 1:05 PM, mouthbow <[email protected]> wrote:
> Hi all,
>
> I know that maybe this is a very basic question but after reading a
> lot of webpages I cannot solve this problem.
>
> I have three tables: Patients
> (Hospital_Id[uniqueidentifier],Patient_Id[int],...), Addresses
> (adress_id[uniqueidentifier]....) and PatientsAddresses (Hospital_id,
> Patient_Id, Address_Id). Fields in parenthesis represent key.
>
> I have full control on database and I have read that composite Id's
> are not recommended but really I don't know in that case for example
> how can I be sure that an address will be associated with a patient
> only one time.
>
> In case that the tables are correct, I'm trying to make the mapping
> but i can't.
>
> the relevant parts of hbm file
>
> <class name="Domain.Entity.Patients, Domain" table="Patients"
>  dynamic-update="true"
>  dynamic-insert="true" >
>
> <composite-id name="Id" class="Domain.Components.PairIdComponent,
> Domain">
>        <key-property name="Key1" column="Hospital_Id" type="System.Guid"/>
>        <key-property name="Key2" column="Patient_id" type="System.Int32"/>
> </composite-id>
>
>
> ......
>
>    <set name="PatientsAddresses" table="PatientsAddresses"
> lazy="false" cascade="none" inverse="true" access="field.pascalcase-
> underscore">
>          <key>
>                <column name="Patient_Id" />
>                <column name="Hospital_Id" />
>          </key>
>      <many-to-many class="Domain.Entity.Addresses, Domain"  >
>                <column name="Address_ID" />
>          </many-to-many>
>    </set>
>
> This is the only mode I have found that the configuration of
> nhibernate does not raise any exception but when I try to get some
> data I get this exception:
>
> Operand type clash: uniqueidentifier is incompatible with int.
>
> I'm sure that there is something that I have not understood yet about
> set's and many-to-many associations. Or maybe I cannot do this as this
> way.
>
> Any help would be really aprreciated.
>
> Mouthbow
>
> --
> You received this message because you are subscribed to the Google Groups 
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to