Hola Rodrigo, Aunque tu modelo tiene sentido, si Subsiniestro no es una entidad persistente y es sólo una interfaz, no puedes tener mapeada una colección que haga referencia a N distintos tipos de entidades. Es decir, para que lo que quieres funcionara con NHibernate, el interfaz ISubsiniestro debería ser más bien una clase Subsiniestro, y de ésta deberían heredar el resto, con la estrategia de mapeo de herencia que consideres más adecuada.
O igual me equivoco y sí hay una manera de hacerlo, pero desde luego yo no la conozco. Francisco A. Lozano On Thu, Jan 15, 2009 at 16:17, Rodrigo Juarez <[email protected]> wrote: > > Hola > > El siniestro tiene los datos principales del accidente > > Un siniestro contiene subsiniestros > > Los subsiniestros son cada una de las personas, vehiculos o propiedades > afectadas > > Subsiniestro es una superclase abstracta, personas, vehiculos, propiedades, > subclases de subsiniestro > > Saludos! > > Rodrigo Juarez > [email protected] > http://rodrigojuarez.com.ar > http://intap.com.ar > -----Mensaje original----- > De: [email protected] > [mailto:[email protected]] En nombre de Raul Lopez > Enviado el: jueves, 15 de enero de 2009 12:08 p.m. > Para: [email protected] > Asunto: [NHibernate-Hispano] Re: Creacion de lista de subclases > > > Hola Rodrigo, > > No estoy entendiendo el modelo. > En tu dominio hay siniestros, propiedades, vehiculos, lesionados... > Que es un subsiniestro? > > Saludos, > > Raul Lopez > > Rodrigo Juarez escribió: >> Hola >> >> >> >> Tengo una clase Siniestro, que posee una colección de subsiniestros, los >> cuales pertenecen a distintas clases >> >> >> >> Los subsiniestros implementan ISubSiniestro, y en este momento, la unica >> clase que lo implementa es Lesionados, aunque luego agregare Propiedades >> y Vehiculos >> >> >> >> Como se puede ver, la clase siniestro, tiene una lista de todos los >> ISubSiniestros, lo que yo necesito saber, es si con esta estrategia, >> puedo tener tres listas distintas dentro de siniestro, Lesionados, >> Propiedades y Vehiculos y como se mapean, en lugar de tener una sola >> lista de ISubSiniestro. >> >> >> >> Desde ya muchas gracias >> >> >> >> >> >> Mapeo Lesionados >> >> > ---------------------------------------------------------------------------- > ------- >> >> <?xml version="1.0" encoding="utf-8" ?> >> >> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >> namespace="Gestion.Domain.Seguros" assembly="Gestion.Domain.Seguros"> >> >> <joined-subclass name="Lesionados" lazy="true" table="Lesionados" >> extends="ISubSiniestro"> >> >> <key column="uid"/> >> >> <property name="Transportado"/> >> >> <many-to-one name="Lesion" class="Lesion"/> >> >> <many-to-one name="EstadoGestion" class="EstadoGestion"/> >> >> </joined-subclass> >> >> </hibernate-mapping> >> >> >> >> >> >> Mapeo ISubSiniestro >> >> > ---------------------------------------------------------------------------- > ------- >> >> <?xml version="1.0" encoding="utf-8" ?> >> >> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >> namespace="Gestion.Domain.Seguros" assembly="Gestion.Domain.Seguros"> >> >> <class name="ISubSiniestro" lazy="true"> >> >> <id name="Id" type="Int64" column="uid" unsaved-value="0"> >> >> <generator class="NHibernate.Id.TableHiLoGenerator"> >> >> <param name="table">uid_table</param> >> >> <param name="column">next_hi_value_column</param> >> >> </generator> >> >> </id> >> >> >> >> <many-to-one name="Siniestro" class="Siniestro"/> >> >> >> >> <!--Datos del Damnificado--> >> >> <component name="Damnificado" >> class="Gestion.Domain.Seguros.Persona,Gestion.Domain.Seguros"> >> >> <property name="Nombre" length ="100" column="DamnificadoNombre"/> >> >> <property name="Documento" length="15" > column="DamnificadoDocumento"/> >> >> <property name="EstadoCivil" column="DamnificadoEstadoCivil"/> >> >> <property name="Sexo" column="DamnificadoSexo"/> >> >> <property name="Nacimiento" column="DamnificadoNacimiento" >> length="8"/> >> >> <property name="Nacionalidad" length="50" >> column="DamnificadoNacionalidad"/> >> >> <property name="Telefono" length="30" column="DamnificadoTelefono"/> >> >> <component name="Direccion" >> class="Gestion.Domain.Seguros.Direccion, Gestion.Domain.Seguros"> >> >> <property name="Calle" length="100" column="DamnificadoCalle"/> >> >> <property name="Numero" column="DamnificadoCalleNumero"/> >> >> <property name="CP" length="7" column="DamnificadoCP"/> >> >> <property name="Localidad" length="50" >> column="DamnificadoLocalidad"/> >> >> <property name="Provincia" length="50" >> column="DamnificadoProvincia"/> >> >> </component> >> >> </component> >> >> >> >> <property name="SubSiniestroCategoria"/> >> >> >> >> <property name="Observaciones" length ="10000"/> >> >> <property name="Situacion" length ="10000"/> >> >> >> >> <property name="Reclamo"/> >> >> <property name="Indemnizacion"/> >> >> <property name="Demanda"/> >> >> >> >> </class> >> >> </hibernate-mapping> >> >> >> >> >> >> Mapeo Siniestro >> >> > ---------------------------------------------------------------------------- > ------- >> >> <?xml version="1.0" encoding="utf-8" ?> >> >> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >> namespace="Gestion.Domain.Seguros" assembly="Gestion.Domain.Seguros"> >> >> >> >> <class name="Siniestro" lazy="true"> >> >> >> >> <id name="Id" type="Int64" column="uid" unsaved-value="0"> >> >> <generator class="NHibernate.Id.TableHiLoGenerator"> >> >> <param name="table">uid_table</param> >> >> <param name="column">next_hi_value_column</param> >> >> </generator> >> >> </id> >> >> >> >> <!--Datos del Siniestro--> >> >> <property name="Fecha"/> >> >> <property name="Numero"/> >> >> <component name="DireccionAccidente" >> class="Gestion.Domain.Seguros.Direccion, Gestion.Domain.Seguros"> >> >> <property name="Calle" length="100" column="AccidenteCalle"/> >> >> <property name="Numero" column="AccidenteCalleNumero"/> >> >> <property name="CP" length="7" column="AccidenteCP"/> >> >> <property name="Localidad" length="50" column="AccidenteLocalidad"/> >> >> <property name="Provincia" length="50" column="AccidenteProvincia"/> >> >> </component> >> >> <property name="Comisaria"/> >> >> <property name="Velocidad"/> >> >> <property name="Visibilidad" length="20"/> >> >> <property name="Bocina"/> >> >> <property name="Lluvia"/> >> >> <property name="Luces"/> >> >> <property name="ManoUnica"/> >> >> >> >> <!--Datos del Asegurado--> >> >> <property name="Poliza"/> >> >> <property name="Linea" length="50"/> >> >> <property name="Interno" length="50"/> >> >> <many-to-one name="Asegurado" class="Asegurado"/> >> >> >> >> <!--Datos del Chofer--> >> >> <component name="Chofer" >> class="Gestion.Domain.Seguros.Persona,Gestion.Domain.Seguros"> >> >> <property name="Nombre" length ="100" column="ChoferNombre"/> >> >> <property name="Documento" length="15" column="ChoferDocumento"/> >> >> <property name="EstadoCivil" column="ChoferEstadoCivil"/> >> >> <property name="Sexo" column="ChoferSexo"/> >> >> <property name="Nacimiento" column="ChoferNacimiento" length="8"/> >> >> <property name="Nacionalidad" length="50" >> column="ChoferNacionalidad"/> >> >> <property name="Telefono" length="30" column="ChoferTelefono"/> >> >> <component name="Direccion" >> class="Gestion.Domain.Seguros.Direccion, Gestion.Domain.Seguros"> >> >> <property name="Calle" length="100" column="ChoferCalle"/> >> >> <property name="Numero" column="ChoferCalleNumero"/> >> >> <property name="CP" length="7" column="ChoferCP"/> >> >> <property name="Localidad" length="50" column="ChoferLocalidad"/> >> >> <property name="Provincia" length="50" column="ChoferProvincia"/> >> >> </component> >> >> </component> >> >> <property name="ChoferDeclaracion" type="string" length="10000"/> >> >> >> >> <property name="LicenciaClase" length="50"/> >> >> <property name="LicenciaNumero"/> >> >> <property name="LicenciaVencimiento" length="8" /> >> >> <property name="AntiguedadEmpresa"/> >> >> <property name="AntiguedadConductorProfesional"/> >> >> >> >> <!--Datos del vehiculo de pasajeros--> >> >> <property name="VehiculoMarca" length ="100"/> >> >> <property name="VehiculoTipo" length ="20"/> >> >> <property name="Patente" length ="10"/> >> >> <property name="MotorNumero" length ="20"/> >> >> <property name="Anio"/> >> >> >> >> <!--Testigos (Componente persona)--> >> >> >> >> <!--SubClases de SubSiniestro--> >> >> >> >> <!--Vehiculos accidentados--> >> >> >> >> <!--Propiedades dañadas--> >> >> >> >> <!--Lesionados Transportados / No Transportados--> >> >> <bag name="SubSiniestros" inverse="true" >> cascade="all-delete-orphan" lazy="false"> >> >> <key column="Siniestro"/> >> >> <one-to-many class="ISubSiniestro"/> >> >> </bag> >> >> >> >> </class> >> >> >> >> </hibernate-mapping> >> >> >> >> Clase Lesionados >> >> > ---------------------------------------------------------------------------- > ------- >> >> namespace Gestion.Domain.Seguros >> >> { >> >> public class Lesionados:ISubSiniestro >> >> { >> >> >> >> public Lesionados() >> >> { >> >> SubSiniestroCategoria = > Seguros.SubSiniestroCategoria.Lesiones; >> >> } >> >> >> >> #region Implementation of ISubSiniestro >> >> >> >> public virtual long Id { get; set; } >> >> public virtual Siniestro Siniestro { get; set; } >> >> public virtual Persona Damnificado { get; set; } >> >> public virtual string Observaciones { get; set; } >> >> public virtual string Situacion { get; set; } >> >> public virtual double Reclamo { get; set; } >> >> public virtual double Indemnizacion { get; set; } >> >> public virtual double Demanda { get; set; } >> >> public virtual SubSiniestroCategoria SubSiniestroCategoria { >> get; set; } >> >> >> >> #endregion >> >> >> >> public virtual Lesion Lesion { get; set; } >> >> public virtual EstadoGestion EstadoGestion { get; set; } >> >> public virtual bool Transportado { get; set; } >> >> >> >> //TODO: crear wrapper y usar en donde se llaman a estos metodos >> >> public virtual string Nombre >> >> { >> >> get >> >> { >> >> return Damnificado.Nombre; >> >> } >> >> } >> >> >> >> //TODO: crear wrapper y usar en donde se llaman a estos metodos >> >> public virtual string DocumentoNumero >> >> { >> >> get >> >> { >> >> return Damnificado.Documento; >> >> } >> >> } >> >> >> >> } >> >> } >> >> >> >> >> >> >> >> Clase ISubSiniestro >> >> > ---------------------------------------------------------------------------- > ------- >> >> using System; >> >> >> >> namespace Gestion.Domain.Seguros >> >> { >> >> public interface ISubSiniestro >> >> { >> >> >> >> Int64 Id { get; set; } >> >> Siniestro Siniestro { get; set; } >> >> Persona Damnificado { get; set; } >> >> >> >> string Observaciones { get; set; } >> >> string Situacion { get; set; } >> >> >> >> double Reclamo { get; set; } >> >> double Indemnizacion { get; set; } >> >> double Demanda { get; set; } >> >> >> >> SubSiniestroCategoria SubSiniestroCategoria { get; set; } >> >> >> >> // IList<GestionPendiente> Pendientes { get; set; } >> >> >> >> } >> >> } >> >> >> >> >> >> Clase Siniestro >> >> > ---------------------------------------------------------------------------- > ------- >> >> using System; >> >> using System.Collections.Generic; >> >> >> >> namespace Gestion.Domain.Seguros >> >> { >> >> public class Siniestro >> >> { >> >> >> >> public Siniestro() >> >> { >> >> SubSiniestros = new List<ISubSiniestro>(); >> >> } >> >> >> >> public virtual Int64 Id { get; set; } >> >> >> >> // Datos del Siniestro >> >> public virtual DateTime Fecha { get; set; } >> >> public virtual Int32 Numero { get; set; } >> >> public virtual Direccion DireccionAccidente { get; set; } >> >> public virtual int Comisaria { get; set; } >> >> public virtual int Velocidad { get; set; } >> >> public virtual string Visibilidad { get; set; } >> >> public virtual bool Bocina { get; set; } >> >> public virtual bool Lluvia { get; set; } >> >> public virtual bool Luces { get; set; } >> >> public virtual bool ManoUnica { get; set; } >> >> >> >> // Datos del Asegurado >> >> public virtual int Poliza { get; set; } >> >> public virtual string Linea { get; set; } >> >> public virtual string Interno { get; set; } >> >> public virtual Asegurado Asegurado { get; set; } >> >> public virtual string VehiculoMarca { get; set; } >> >> public virtual string VehiculoTipo { get; set; } >> >> public virtual string Patente { get; set; } >> >> public virtual string MotorNumero { get; set; } >> >> public virtual int Anio { get; set; } >> >> >> >> // Datos del Chofer >> >> public virtual Persona Chofer { get; set; } >> >> // Falta en UI >> >> public virtual string ChoferDeclaracion { get; set; } >> >> public virtual string LicenciaClase { get; set; } >> >> public virtual string LicenciaNumero { get; set; } >> >> public virtual string LicenciaVencimiento { get; set; } >> >> public virtual int AntiguedadEmpresa { get; set; } >> >> public virtual int AntiguedadConductorProfesional { get; set; } >> >> >> >> // Lesionados >> >> public virtual IList<ISubSiniestro> SubSiniestros { get; set; } >> >> >> >> } >> >> } >> >> >> >> >> >> Rodrigo Juarez >> >> [email protected] <mailto:[email protected]> >> >> http://rodrigojuarez.com.ar >> >> http://intap.com.ar >> >> >> >> >> > > > > > > > --~--~---------~--~----~------------~-------~--~----~ Para escribir al Grupo, hágalo a esta dirección: [email protected] Para más, visite: http://groups.google.com/group/NHibernate-Hispano -~----------~----~----~----~------~----~------~--~---
