OK. First. Let me show you the diagram.
Explanation:
The table
Tipos_Documento has Different Identification Types for Patients. Id: IdTipoDocumento
The table
Pacientes has Patient's personal information. Id: IdPacientes.
The table Pacientes_Documentos has Identifications that the patients have. Since they can have more than one, i use this table.
By meaning Identification, i'm talking about Driver's Licence, or different documents that help identify a person. SO. the user can insert more than one identification for each patient.
As you can see, the table
Pacientes_Documentos, Has two Foreign Keys. One Is the Patient ID (
IdPaciente) and the other is the Identification type (
IdTipoDocumento). This two make a unique record. So, each Patient can have as many Identifications as Identification types are on the Tipos_Documentos table has.
So...
Here is the maping of the classes.
TipoDocumento (for table Tipos_Documentos)
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Negocios.TipoDocumento, Capas" table="Tipos_Documento">
<id name="Id" column="IdTipoDocumento" type="int">
<generator class="assigned" />
</id>
<property name="Nombre" />
</class>
</hibernate-mapping>
Paciente (for table Pacientes)Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Negocios.Medicina.Paciente, Capas" table="Pacientes">
<id name="Id" column="IdPaciente" type="int">
<generator class="assigned" />
</id>
<property name="Nombre" />
<property name="Apellido" />
<property name="DomicilioCalle" column="DomCalle" />
<property name="DomicilioNumero" column="DomNumero" />
<property name="DomicilioMonoblock" column="DomMonoblock" />
<property name="DomicilioPiso" column="DomPiso" />
<property name="DomicilioDepartamento" column="DomDepartamento" />
<property name="DomicilioCiudad" column="DomCiudad" />
<property name="DomicilioProvincia" column="DomProvincia" />
<property name="DomicilioPais" column="DomPais" />
<property name="Sexo" column="Sexo" />
<set name="Documentos" cascade="all" lazy="true">
<key column="IdPaciente" />
<one-to-many class="Negocios.Medicina.PacienteDocumento, Capas" />
</set>
</class>
</hibernate-mapping>
Paciente_Documento (for table Pacientes_Documentos)Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Negocios.Medicina.PacienteDocumento, Capas" table="Pacientes_Documentos">
<composite-id>
<key-many-to-one name="IdPaciente" class="Negocios.Medicina.Paciente, Capas" column="IdPaciente" />
<key-many-to-one name="IdTipoDocumento" class="Negocios.TipoDocumento, Capas" column="IdTipoDocumento"/>
</composite-id>
<property name="NumeroDocumento" column="Numero" />
</class>
</hibernate-mapping>
So... on the Paciente Class, there is the property Documentos, which is an IDictionary. It would be the collection of Identifications, the patient has.
It worked really well before i added this new property.
But now, when I run my GetPaciente Method, I get the following error:
Quote:
Invalid mapping information specified for type Negocios.Medicina.Paciente, check your mapping file for property type mismatches
As i said before, it worked really great before adding this new property. So, I guess the problem must be on the way i'm relating the tables.
Can any of you give me a hand?
Please let me know if you need something else to figure it out.
Thanks in advance!
Juanu