These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Invalid Cast (check your mapping for property type mismatche
PostPosted: Tue May 11, 2010 9:14 am 
Newbie

Joined: Tue Feb 09, 2010 11:32 am
Posts: 5
Hi All,

I and having a problem with my mapping.

Invalid Cast (check your mapping for property type mismatches); setter of NISG.Framework.PatientModule.Domain.Classes.PatientElectronicContact

below is the mapping file:

Code:
<class name="NISG.Framework.PatientModule.Domain.Classes.Patient, NISG.Framework.PatientModule.Domain" table="tbl_patients" lazy="false">
        <id name="Id"
            type="System.Guid"
            column="patient_id">
            <generator class="guid.comb"/>
        </id>
        <property name="DateOfBirth" column="date_of_birth"/>
        <property name="DateOfDeath" column="date_of_death"/>
        <property name="GenderAtBirth" column="gender_at_birth"/>
        <property name="MaritalStatus" column="marital_status"/>
        <property name ="CurrentGender" column="current_gender"/>

        <bag name="Names" cascade="all-delete-orphan" inverse="true" lazy="false">
            <key column="patient_id" />
            <one-to-many class="NISG.Framework.PatientModule.Domain.Classes.PatientName, NISG.Framework.PatientModule.Domain" />
        </bag>

        <bag name="PatientIdentifiers" cascade="all-delete-orphan" inverse="true" lazy="false">
            <key column="patient_id"/>
            <one-to-many class="NISG.Framework.PatientModule.Domain.Classes.PatientIdentifier, NISG.Framework.PatientModule.Domain"/>
        </bag>
     
        <bag name="Addresses" cascade="all" inverse="true" lazy="false">
            <key column="patient_id"/>
            <one-to-many class="NISG.Framework.PatientModule.Domain.Classes.PatientAddress, NISG.Framework.PatientModule.Domain"/>
        </bag>
     
        <bag name="AssociatedPeople" cascade="all-delete-orphan" inverse="true" lazy="false">
            <key column="patient_id"/>
            <one-to-many class="NISG.Framework.PatientModule.Domain.Classes.AssociatedPerson, NISG.Framework.PatientModule.Domain"/>
        </bag>
       
        <bag name="TelephoneNumbers" cascade="all-delete-orphan" inverse="true" lazy="false">
            <key column="patient_id"/>
            <one-to-many class="NISG.Framework.PatientModule.Domain.Classes.PatientTelephoneNumber, NISG.Framework.PatientModule.Domain"/>
        </bag>
        <bag name="EletronicContacts" cascade="all-delete-orphan" inverse="true" lazy="false">
            <key column="patient_id"/>
            <one-to-many class="NISG.Framework.PatientModule.Domain.Classes.PatientElectronicContact, NISG.Framework.PatientModule.Domain"/>
        </bag>
    </class>


Below linked mapping class:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
    <class name="NISG.Framework.PatientModule.Domain.Classes.PatientElectronicContact, NISG.Framework.PatientModule.Domain" table="tbl_patient_eletronic_contacts" lazy="false">
        <id name="Id"
            type="System.Guid"
            unsaved-value="00000000-0000-0000-0000-000000000000"
            column="patient_electronic_contact_id">
            <generator class="guid.comb"/>
        </id>
        <!--<composite-id>
            <key-many-to-one name="Patient_Id" class="NISG.Framework.PatientModule.Domain.Classes.Patient, NISG.Framework.PatientModule.Domain" column="patient_id"/>
            <key-property name="id" column="patient_electronic_contact_id" />
        </composite-id>-->
        <property name="Url" column="url" type="StringClob"/>
        <property name="Type" column="type" type ="StringClob"/>
        <many-to-one name="Patient_Id" class="NISG.Framework.PatientModule.Domain.Classes.Patient, NISG.Framework.PatientModule.Domain" column="patient_id"/>
    </class>
</hibernate-mapping>


I have been looking at this for a couple of days now and I really help.

Thanks in advance


Top
 Profile  
 
 Post subject: Re: Invalid Cast (check your mapping for property type mismatche
PostPosted: Tue May 11, 2010 10:39 am 
Beginner
Beginner

Joined: Fri Feb 27, 2009 6:07 am
Posts: 38
Location: Moscow,Russia
Show code NISG.Framework.PatientModule.Domain.Classes.Patient with EletronicContacts collection.


Top
 Profile  
 
 Post subject: Re: Invalid Cast (check your mapping for property type mismatche
PostPosted: Tue May 11, 2010 10:45 am 
Newbie

Joined: Tue Feb 09, 2010 11:32 am
Posts: 5
Code:
namespace NISG.Framework.PatientModule.Domain.Classes
{
    using System;
    using System.Collections.Generic;
    using NISG.Framework.CoreModule.Domain.Classes;
    using NISG.Framework.PatientModule.Domain.Classes.Interfaces;
    using System.Runtime.Serialization;
   
    public class Patient : Person<PatientAddress, PatientName, PatientTelephoneNumber, PatientElectronicContact>, IPatient
    {
     
        public DateTime DateOfBirth { get; set; }

       
        public DateTime DateOfDeath { get; set; }

     
        public char GenderAtBirth { get; set; }

       
        public char MaritalStatus { get; set; }

       
        //public VerificationLevel DateOfBirthVerifictionLevel { get; set; }

       
        //public VerificationLevel DateOfDeathVerifictionLevel { get; set; }

       
        public IList<AssociatedPerson> AssociatedPeople { get; set; }


        public IList<PatientIdentifier> PatientIdentifiers { get; set; }

       
        public override IList<PatientAddress> Addresses { get; set; }

     
        public override IList<PatientName> Names { get; set; }

     
        public override IList<PatientTelephoneNumber> TelephoneNumbers { get; set; }

     
        public override IList<PatientElectronicContact> EletronicContacts { get; set; }


        public override char CurrentGender { get; set; }


        public Patient(Nullable<Guid> id)
            : base(id)
        {
           
        }

        public Patient()
            : base()
        {

         

        }
    }
}


Top
 Profile  
 
 Post subject: Re: Invalid Cast (check your mapping for property type mismatche
PostPosted: Tue May 11, 2010 11:29 am 
Beginner
Beginner

Joined: Fri Feb 27, 2009 6:07 am
Posts: 38
Location: Moscow,Russia
May be occur exception when NHibernate try set EletronicContacts property.


Top
 Profile  
 
 Post subject: Re: Invalid Cast (check your mapping for property type mismatche
PostPosted: Tue May 11, 2010 11:35 am 
Newbie

Joined: Tue Feb 09, 2010 11:32 am
Posts: 5
Do you have any idea why this error would be occuring at that stage.


Top
 Profile  
 
 Post subject: Re: Invalid Cast (check your mapping for property type mismatche
PostPosted: Wed May 12, 2010 2:53 am 
Beginner
Beginner

Joined: Fri Feb 27, 2009 6:07 am
Posts: 38
Location: Moscow,Russia
I have idea as find error.
Download NHibernate with source.
Run Visual Studio in Debug mode.
After occuring exception view call stack.


Top
 Profile  
 
 Post subject: Re: Invalid Cast (check your mapping for property type mismatche
PostPosted: Fri May 14, 2010 7:03 am 
Newbie

Joined: Tue Feb 09, 2010 11:32 am
Posts: 5
I have noticed something weird with the sql being generated by nhibernate.

For each Id (primary and foreign) it is selecting duplicate values.

SQL:

SELECT eletronicc0_.patient_id as patient4_1_,
eletronicc0_.patient_electronic_contact_id as patient1_1_,
eletronicc0_.patient_electronic_contact_id as patient1_11_0_,

eletronicc0_.url as url11_0_,
eletronicc0_.type as type11_0_,
eletronicc0_.patient_id as patient4_11_0_
FROM tbl_patient_eletronic_contacts eletronicc0_
WHERE eletronicc0_.patient_id = 'bb92c011-e25a-4c6d-9993-9d6c00f02bb1' /* @p0 */

I think that is what is causing the type mismatch.

Does anyone have any ideas why this is happening?

I am really pushed for time now and would really appreciate any help.

Thanks in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.