Error enviado por NH, esto me pasa con varias entidades mas, tengo 743
entidades.

Gracias por la ayuda.

Saludos


2007/1/9, Ezequiel Jadib <[EMAIL PROTECTED]>:
>
>  Manda el mapping.
>
> Acostumbrense a mandar el mapping cuando tienen un error, asi es mucho mas
> facil descubrir que anda pasando.
>
> Saludos!
>  ------------------------------
> rdi2k <http://www.rdi2k.com/> | Ezequiel Jadib <[EMAIL PROTECTED]> | MSN:
> [EMAIL PROTECTED] | Blogs: http://geeks.ms/blogs/ejadib/ (ES) -
> ejadib.wordpress.com (EN)
>
> ----- Original Message -----
> *From:* Daniel Mendiola <[EMAIL PROTECTED]>
> *To:* [email protected]
> *Sent:* Tuesday, January 09, 2007 1:18 PM
> *Subject:* [NHibernate-Hispano] NHibernate.MappingException: Foreign key
> in table
>
> Sr(s) A ver si alguien se daría cuenta de este error.
> La idea en el diagrama es la siguiente.
>
>
> Tengo una entidad que tiene una clave compuesta con 3 Campos
>
> y arrastra toda la clave a otra entidad.
>
> Compilar compila, pero luego me da un error que es el que pego en el
> asunto!
>
> Gracias
>
>
>
>
>
> >
>


--~--~---------~--~----~------------~-------~--~----~
Para escribir al Grupo, hágalo a esta dirección: 
[email protected]
Para más, visite: http://groups-beta.google.com/group/NHibernate-Hispano
-~----------~----~----~----~------~----~------~--~---
using System;
using System.Collections.Generic;

namespace Persistencia.Entities
{
[Serializable]
public class MPE_Ingresos_Mercado
{
     private CC_MPE_Ingresos_MercadoLin CC_MPE_Ingresos_MercadoAtrib;
     private APR_Mercado_Producto rc_Id_Producto;
     private AD_Red_POS rc_Id_Nodo;
     private APC_Listas rc_Id_Lista;
     private APR_Mercado_Producto rc_Id_Mercado;
     private APR_Mercado_Producto rc_Id_Segmento;
     private IList<MPE_Mercado_Prevision> 
mIli_MPE_Mercado_Prevision_Id_Presupuesto;


     public MPE_Ingresos_Mercado()
     {
     }

     public virtual CC_MPE_Ingresos_MercadoLin CC_MPE_Ingresos_Mercado
     {
         get 
          {
              return this.CC_MPE_Ingresos_MercadoAtrib;
          }
         set
          {
              this.CC_MPE_Ingresos_MercadoAtrib = value;
          }
     }
     public virtual APR_Mercado_Producto Id_Producto
     {
         get 
             {
             return rc_Id_Producto;
             }
         set 
             {
             rc_Id_Producto = value;
             }
     }

     public virtual AD_Red_POS Id_Nodo
     {
         get 
             {
             return rc_Id_Nodo;
             }
         set 
             {
             rc_Id_Nodo = value;
             }
     }

     public virtual APC_Listas Id_Lista
     {
         get 
             {
             return rc_Id_Lista;
             }
         set 
             {
             rc_Id_Lista = value;
             }
     }

     public virtual APR_Mercado_Producto Id_Mercado
     {
         get 
             {
             return rc_Id_Mercado;
             }
         set 
             {
             rc_Id_Mercado = value;
             }
     }

     public virtual APR_Mercado_Producto Id_Segmento
     {
         get 
             {
             return rc_Id_Segmento;
             }
         set 
             {
             rc_Id_Segmento = value;
             }
     }

     public virtual IList<MPE_Mercado_Prevision> MPE_Mercado_Prevision
     {
         get
         {
             return this.mIli_MPE_Mercado_Prevision_Id_Presupuesto;
         }
         set
         {
             this.mIli_MPE_Mercado_Prevision_Id_Presupuesto = value;
         }
     }
}
[Serializable]
public class CC_MPE_Ingresos_MercadoLin
{
         private int m_iId_Presupuesto;
         private int m_iId_Capitulo;
         private int m_iId_Ingresos_Mercado;
     public CC_MPE_Ingresos_MercadoLin(int Id_Presupuesto,int Id_Capitulo,int 
Id_Ingresos_Mercado)
     {
     this.m_iId_Presupuesto=Id_Presupuesto;
     this.m_iId_Capitulo=Id_Capitulo;
     this.m_iId_Ingresos_Mercado=Id_Ingresos_Mercado;
     }
     public CC_MPE_Ingresos_MercadoLin()
     {
     }
     public virtual int Id_Presupuesto
     {
         get 
             {
             return m_iId_Presupuesto;
             }
         set 
             {
             m_iId_Presupuesto = value;
             }
     }

     public virtual int Id_Capitulo
     {
         get 
             {
             return m_iId_Capitulo;
             }
         set 
             {
             m_iId_Capitulo = value;
             }
     }

     public virtual int Id_Ingresos_Mercado
     {
         get 
             {
             return m_iId_Ingresos_Mercado;
             }
         set 
             {
             m_iId_Ingresos_Mercado = value;
             }
     }

     public override int GetHashCode()
     {
     int hash = 57;
     hash = 27 ^ hash ^      this.Id_Presupuesto.GetHashCode()^     
this.Id_Capitulo.GetHashCode()^     this.Id_Ingresos_Mercado.GetHashCode();
     return hash;
     }
     public override bool Equals(object obj)
     {
     if (obj == null || GetType() != obj.GetType())
     {
         return false;
     }
      return 
(this.Id_Presupuesto==((CC_MPE_Ingresos_MercadoLin)obj).m_iId_Presupuesto) && 
(this.Id_Capitulo==((CC_MPE_Ingresos_MercadoLin)obj).m_iId_Capitulo) && 
(this.Id_Ingresos_Mercado==((CC_MPE_Ingresos_MercadoLin)obj).m_iId_Ingresos_Mercado);
     }
}
}
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Persistencia" namespace="Persistencia.Entities">
<class name="MPE_Ingresos_Mercado" table="MPE_Ingresos_Mercado" >

     <composite-id name ="CC_MPE_Ingresos_Mercado" class ="CC_MPE_Ingresos_MercadoLin" unsaved-value="any">
       <key-property name="Id_Presupuesto" column="Id_Presupuesto" type="Int32" length="5" />
       <key-property name="Id_Capitulo" column="Id_Capitulo" type="Int32" length="5" />
       <key-property name="Id_Ingresos_Mercado" column="Id_Ingresos_Mercado" type="Int32" length="5" />
     </composite-id>

<many-to-one name="Id_Producto" column="Id_Producto" class="APR_Mercado_Producto" />
<many-to-one name="Id_Nodo" column="Id_Nodo" class="AD_Red_POS" />
<many-to-one name="Id_Lista" column="Id_Lista" class="APC_Listas" />
<many-to-one name="Id_Mercado" column="Id_Mercado" class="APR_Mercado_Producto" />
<many-to-one name="Id_Segmento" column="Id_Segmento" class="APR_Mercado_Producto" />
     <bag name="MPE_Mercado_Prevision" cascade="none" >
             <key column="Id_Presupuesto"/>
             <one-to-many class="MPE_Mercado_Prevision"/>
     </bag>
</class>

</hibernate-mapping>
using System;
using System.Collections.Generic;

namespace Persistencia.Entities
{
[Serializable]
public class APR_Mercado_Producto
{
     private CC_APR_Mercado_ProductoLin CC_APR_Mercado_ProductoAtrib;
     private APR_Tipos_Estrategias_Crecimiento 
rc_Id_Tipo_Estrategia_Crecimiento;
     private APR_Tipos_Explotacion rc_Id_Tipo_Explotacion;
     private APR_Tipos_Modo_Entrega rc_Id_Tipo_Modo_Entrega;
     private DateTime m_dtFecha_Inicio_Actividad;
     private IList<AD_Canal_Mercado_Producto> 
mIli_AD_Canal_Mercado_Producto_Id_Mercado;
     private IList<AD_Distribucion_Mercado_Producto> 
mIli_AD_Distribucion_Mercado_Producto_Id_Mercado;
     private IList<AM_Caracteristicas_Reacciones_Mercados> 
mIli_AM_Caracteristicas_Reacciones_Mercados_Id_Mercado;
     private IList<AM_Estimaciones_Mercados_Productos> 
mIli_AM_Estimaciones_Mercados_Productos_Id_Mercado;
     private IList<AM_Sectores_Estrategicos> 
mIli_AM_Sectores_Estrategicos_Id_Mercado;
     private IList<APC_Objetivos_Precios> mIli_APC_Objetivos_Precios_Id_Mercado;
     private IList<APP_Foco_Mercado_Producto> 
mIli_APP_Foco_Mercado_Producto_Id_Mercado;
     private IList<APR_Bitacora_Ciclo_Vida_Mercados> 
mIli_APR_Bitacora_Ciclo_Vida_Mercados_Id_Mercado;
     private IList<APR_Estrategia_Marca_Mercado_Producto> 
mIli_APR_Estrategia_Marca_Mercado_Producto_Id_Mercado;
     private IList<APR_Posicionamiento> mIli_APR_Posicionamiento_Id_Mercado;
     private IList<IM_Enfoque_Mercado_Producto> 
mIli_IM_Enfoque_Mercado_Producto_Id_Mercado;
     private IList<MPE_Costeo_Unitario> mIli_MPE_Costeo_Unitario_Id_Mercado;
     private IList<MPE_Foco_Mercado_Producto> 
mIli_MPE_Foco_Mercado_Producto_Id_Mercado;
     private IList<MPE_Ingresos_Mercado> mIli_MPE_Ingresos_Mercado_Id_Mercado;
     private IList<MPE_Margen> mIli_MPE_Margen_Id_Mercado;
     private IList<OP_Asignacion_Territorial_Productos> 
mIli_OP_Asignacion_Territorial_Productos_Id_Mercado;
     private IList<OP_Estructura_Comercial_Mercados_Productos> 
mIli_OP_Estructura_Comercial_Mercados_Productos_Id_Mercado;
     private IList<PA_Mercados_Productos_Proyectos> 
mIli_PA_Mercados_Productos_Proyectos_Id_Mercado;


     public APR_Mercado_Producto()
     {
     }

     public virtual CC_APR_Mercado_ProductoLin CC_APR_Mercado_Producto
     {
         get 
          {
              return this.CC_APR_Mercado_ProductoAtrib;
          }
         set
          {
              this.CC_APR_Mercado_ProductoAtrib = value;
          }
     }
     public virtual APR_Tipos_Estrategias_Crecimiento 
Id_Tipo_Estrategia_Crecimiento
     {
         get 
             {
             return rc_Id_Tipo_Estrategia_Crecimiento;
             }
         set 
             {
             rc_Id_Tipo_Estrategia_Crecimiento = value;
             }
     }

     public virtual APR_Tipos_Explotacion Id_Tipo_Explotacion
     {
         get 
             {
             return rc_Id_Tipo_Explotacion;
             }
         set 
             {
             rc_Id_Tipo_Explotacion = value;
             }
     }

     public virtual APR_Tipos_Modo_Entrega Id_Tipo_Modo_Entrega
     {
         get 
             {
             return rc_Id_Tipo_Modo_Entrega;
             }
         set 
             {
             rc_Id_Tipo_Modo_Entrega = value;
             }
     }

     public virtual DateTime Fecha_Inicio_Actividad
     {
         get 
             {
             return m_dtFecha_Inicio_Actividad;
             }
         set 
             {
             m_dtFecha_Inicio_Actividad = value;
             }
     }

     public virtual IList<AD_Canal_Mercado_Producto> AD_Canal_Mercado_Producto
     {
         get
         {
             return this.mIli_AD_Canal_Mercado_Producto_Id_Mercado;
         }
         set
         {
             this.mIli_AD_Canal_Mercado_Producto_Id_Mercado = value;
         }
     }
     public virtual IList<AD_Distribucion_Mercado_Producto> 
AD_Distribucion_Mercado_Producto
     {
         get
         {
             return this.mIli_AD_Distribucion_Mercado_Producto_Id_Mercado;
         }
         set
         {
             this.mIli_AD_Distribucion_Mercado_Producto_Id_Mercado = value;
         }
     }
     public virtual IList<AM_Caracteristicas_Reacciones_Mercados> 
AM_Caracteristicas_Reacciones_Mercados
     {
         get
         {
             return this.mIli_AM_Caracteristicas_Reacciones_Mercados_Id_Mercado;
         }
         set
         {
             this.mIli_AM_Caracteristicas_Reacciones_Mercados_Id_Mercado = 
value;
         }
     }
     public virtual IList<AM_Estimaciones_Mercados_Productos> 
AM_Estimaciones_Mercados_Productos
     {
         get
         {
             return this.mIli_AM_Estimaciones_Mercados_Productos_Id_Mercado;
         }
         set
         {
             this.mIli_AM_Estimaciones_Mercados_Productos_Id_Mercado = value;
         }
     }
     public virtual IList<AM_Sectores_Estrategicos> AM_Sectores_Estrategicos
     {
         get
         {
             return this.mIli_AM_Sectores_Estrategicos_Id_Mercado;
         }
         set
         {
             this.mIli_AM_Sectores_Estrategicos_Id_Mercado = value;
         }
     }
     public virtual IList<APC_Objetivos_Precios> APC_Objetivos_Precios
     {
         get
         {
             return this.mIli_APC_Objetivos_Precios_Id_Mercado;
         }
         set
         {
             this.mIli_APC_Objetivos_Precios_Id_Mercado = value;
         }
     }
     public virtual IList<APP_Foco_Mercado_Producto> APP_Foco_Mercado_Producto
     {
         get
         {
             return this.mIli_APP_Foco_Mercado_Producto_Id_Mercado;
         }
         set
         {
             this.mIli_APP_Foco_Mercado_Producto_Id_Mercado = value;
         }
     }
     public virtual IList<APR_Bitacora_Ciclo_Vida_Mercados> 
APR_Bitacora_Ciclo_Vida_Mercados
     {
         get
         {
             return this.mIli_APR_Bitacora_Ciclo_Vida_Mercados_Id_Mercado;
         }
         set
         {
             this.mIli_APR_Bitacora_Ciclo_Vida_Mercados_Id_Mercado = value;
         }
     }
     public virtual IList<APR_Estrategia_Marca_Mercado_Producto> 
APR_Estrategia_Marca_Mercado_Producto
     {
         get
         {
             return this.mIli_APR_Estrategia_Marca_Mercado_Producto_Id_Mercado;
         }
         set
         {
             this.mIli_APR_Estrategia_Marca_Mercado_Producto_Id_Mercado = value;
         }
     }
     public virtual IList<APR_Posicionamiento> APR_Posicionamiento
     {
         get
         {
             return this.mIli_APR_Posicionamiento_Id_Mercado;
         }
         set
         {
             this.mIli_APR_Posicionamiento_Id_Mercado = value;
         }
     }
     public virtual IList<IM_Enfoque_Mercado_Producto> 
IM_Enfoque_Mercado_Producto
     {
         get
         {
             return this.mIli_IM_Enfoque_Mercado_Producto_Id_Mercado;
         }
         set
         {
             this.mIli_IM_Enfoque_Mercado_Producto_Id_Mercado = value;
         }
     }
     public virtual IList<MPE_Costeo_Unitario> MPE_Costeo_Unitario
     {
         get
         {
             return this.mIli_MPE_Costeo_Unitario_Id_Mercado;
         }
         set
         {
             this.mIli_MPE_Costeo_Unitario_Id_Mercado = value;
         }
     }
     public virtual IList<MPE_Foco_Mercado_Producto> MPE_Foco_Mercado_Producto
     {
         get
         {
             return this.mIli_MPE_Foco_Mercado_Producto_Id_Mercado;
         }
         set
         {
             this.mIli_MPE_Foco_Mercado_Producto_Id_Mercado = value;
         }
     }
     public virtual IList<MPE_Ingresos_Mercado> MPE_Ingresos_Mercado
     {
         get
         {
             return this.mIli_MPE_Ingresos_Mercado_Id_Mercado;
         }
         set
         {
             this.mIli_MPE_Ingresos_Mercado_Id_Mercado = value;
         }
     }
     public virtual IList<MPE_Margen> MPE_Margen
     {
         get
         {
             return this.mIli_MPE_Margen_Id_Mercado;
         }
         set
         {
             this.mIli_MPE_Margen_Id_Mercado = value;
         }
     }
     public virtual IList<OP_Asignacion_Territorial_Productos> 
OP_Asignacion_Territorial_Productos
     {
         get
         {
             return this.mIli_OP_Asignacion_Territorial_Productos_Id_Mercado;
         }
         set
         {
             this.mIli_OP_Asignacion_Territorial_Productos_Id_Mercado = value;
         }
     }
     public virtual IList<OP_Estructura_Comercial_Mercados_Productos> 
OP_Estructura_Comercial_Mercados_Productos
     {
         get
         {
             return 
this.mIli_OP_Estructura_Comercial_Mercados_Productos_Id_Mercado;
         }
         set
         {
             this.mIli_OP_Estructura_Comercial_Mercados_Productos_Id_Mercado = 
value;
         }
     }
     public virtual IList<PA_Mercados_Productos_Proyectos> 
PA_Mercados_Productos_Proyectos
     {
         get
         {
             return this.mIli_PA_Mercados_Productos_Proyectos_Id_Mercado;
         }
         set
         {
             this.mIli_PA_Mercados_Productos_Proyectos_Id_Mercado = value;
         }
     }
}
[Serializable]
public class CC_APR_Mercado_ProductoLin
{
         private int m_iId_Mercado;
         private int m_iId_Segmento;
         private int m_iId_Producto;
     public CC_APR_Mercado_ProductoLin(int Id_Mercado,int Id_Segmento,int 
Id_Producto)
     {
     this.m_iId_Mercado=Id_Mercado;
     this.m_iId_Segmento=Id_Segmento;
     this.m_iId_Producto=Id_Producto;
     }
     public CC_APR_Mercado_ProductoLin()
     {
     }
     public virtual int Id_Mercado
     {
         get 
             {
             return m_iId_Mercado;
             }
         set 
             {
             m_iId_Mercado = value;
             }
     }

     public virtual int Id_Segmento
     {
         get 
             {
             return m_iId_Segmento;
             }
         set 
             {
             m_iId_Segmento = value;
             }
     }

     public virtual int Id_Producto
     {
         get 
             {
             return m_iId_Producto;
             }
         set 
             {
             m_iId_Producto = value;
             }
     }

     public override int GetHashCode()
     {
     int hash = 57;
     hash = 27 ^ hash ^      this.Id_Mercado.GetHashCode()^     
this.Id_Segmento.GetHashCode()^     this.Id_Producto.GetHashCode();
     return hash;
     }
     public override bool Equals(object obj)
     {
     if (obj == null || GetType() != obj.GetType())
     {
         return false;
     }
      return (this.Id_Mercado==((CC_APR_Mercado_ProductoLin)obj).m_iId_Mercado) 
&& (this.Id_Segmento==((CC_APR_Mercado_ProductoLin)obj).m_iId_Segmento) && 
(this.Id_Producto==((CC_APR_Mercado_ProductoLin)obj).m_iId_Producto);
     }
}
}
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Persistencia" namespace="Persistencia.Entities">
<class name="APR_Mercado_Producto" table="APR_Mercado_Producto" >

     <composite-id name ="CC_APR_Mercado_Producto" class ="CC_APR_Mercado_ProductoLin" unsaved-value="any">
       <key-property name="Id_Mercado" column="Id_Mercado" type="Int32" length="5" />
       <key-property name="Id_Segmento" column="Id_Segmento" type="Int32" length="5" />
       <key-property name="Id_Producto" column="Id_Producto" type="Int32" length="5" />
     </composite-id>

<many-to-one name="Id_Tipo_Estrategia_Crecimiento" column="Id_Tipo_Estrategia_Crecimiento" class="APR_Tipos_Estrategias_Crecimiento" />
<many-to-one name="Id_Tipo_Explotacion" column="Id_Tipo_Explotacion" class="APR_Tipos_Explotacion" />
<many-to-one name="Id_Tipo_Modo_Entrega" column="Id_Tipo_Modo_Entrega" class="APR_Tipos_Modo_Entrega" />
<property name="Fecha_Inicio_Actividad" column="Fecha_Inicio_Actividad" type="DateTime" />
     <bag name="AD_Canal_Mercado_Producto" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="AD_Canal_Mercado_Producto"/>
     </bag>
     <bag name="AD_Distribucion_Mercado_Producto" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="AD_Distribucion_Mercado_Producto"/>
     </bag>
     <bag name="AM_Caracteristicas_Reacciones_Mercados" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="AM_Caracteristicas_Reacciones_Mercados"/>
     </bag>
     <bag name="AM_Estimaciones_Mercados_Productos" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="AM_Estimaciones_Mercados_Productos"/>
     </bag>
     <bag name="AM_Sectores_Estrategicos" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="AM_Sectores_Estrategicos"/>
     </bag>
     <bag name="APC_Objetivos_Precios" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="APC_Objetivos_Precios"/>
     </bag>
     <bag name="APP_Foco_Mercado_Producto" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="APP_Foco_Mercado_Producto"/>
     </bag>
     <bag name="APR_Bitacora_Ciclo_Vida_Mercados" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="APR_Bitacora_Ciclo_Vida_Mercados"/>
     </bag>
     <bag name="APR_Estrategia_Marca_Mercado_Producto" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="APR_Estrategia_Marca_Mercado_Producto"/>
     </bag>
     <bag name="APR_Posicionamiento" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="APR_Posicionamiento"/>
     </bag>
     <bag name="IM_Enfoque_Mercado_Producto" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="IM_Enfoque_Mercado_Producto"/>
     </bag>
     <bag name="MPE_Costeo_Unitario" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="MPE_Costeo_Unitario"/>
     </bag>
     <bag name="MPE_Foco_Mercado_Producto" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="MPE_Foco_Mercado_Producto"/>
     </bag>
     <bag name="MPE_Ingresos_Mercado" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="MPE_Ingresos_Mercado"/>
     </bag>
     <bag name="MPE_Margen" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="MPE_Margen"/>
     </bag>
     <bag name="OP_Asignacion_Territorial_Productos" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="OP_Asignacion_Territorial_Productos"/>
     </bag>
     <bag name="OP_Estructura_Comercial_Mercados_Productos" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="OP_Estructura_Comercial_Mercados_Productos"/>
     </bag>
     <bag name="PA_Mercados_Productos_Proyectos" cascade="none" >
             <key column="Id_Mercado"/>
             <one-to-many class="PA_Mercados_Productos_Proyectos"/>
     </bag>
</class>

</hibernate-mapping>

Responder a