Un ejemplo más real:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
lazy="false">
        <class name="CustomerDataORM.Server.DataAccess.LegalEntityEntity,
CustomerDataORM.Server.DataAccess" table="LEGAL_ENTITY">
                <composite-id>
                        <key-property name="FinancialEntityIdentifier"
column="FINANCIAL_ENTITY_IDENTIFIER" type="String" />
                        <key-property name="CustomerGIdentifier"
column="CUSTOMER_GIDENTIFIER" type="Int32"/>
                </composite-id>
                <property name="LegalDenominationName"
column="LEGAL_DENOMINATION_NAME" type="String" />
                <property name="ActivityLkpCode" column="ACTIVITY_LKPCODE"
type="String" />
                <property name="SectorLkpCode" column="SECTOR_LKPCODE"
type="String" />
                <property name="LegalStructureLkpCode"
column="LEGAL_STRUCTURE_LKPCODE" type="String" />
                <property name="OrganizedMarketLkpCode"
column="ORGANIZED_MARKET_LKPCODE" type="String" />
        </class>
</hibernate-mapping>

La clase:

namespace CustomerDataORM.Server.DataAccess
{
    public class LegalEntityEntity
    {
        private PrimaryKey<string> financialEntityIdentifier = null;
        private PrimaryKey<int?> customerGIdentifier = null;
        private string legalDenominationName;
        private string activityLkpCode;
        private string sectorLkpCode;
        private string legalStructureLkpCode;
        private string organizedMarketLkpCode;

        public LegalEntityEntity()
        { }

        public PrimaryKey<string> FinancialEntityIdentifier
        {
            get { return this.financialEntityIdentifier; }
            set { this.financialEntityIdentifier = value; }
        }
        public PrimaryKey<int?> CustomerGIdentifier
        {
            get { return this.customerGIdentifier; }
            set { this.customerGIdentifier = value; }
        }
        public string LegalDenominationName
        {
            get { return this.legalDenominationName; }
            set { this.legalDenominationName = value; }
        }
        public string ActivityLkpCode
        {
            get { return this.activityLkpCode; }
            set { this.activityLkpCode = value; }
        }
        public string SectorLkpCode
        {
            get { return this.sectorLkpCode; }
            set { this.sectorLkpCode = value; }
        }
        public string LegalStructureLkpCode
        {
            get { return this.legalStructureLkpCode; }
            set { this.legalStructureLkpCode = value; }
        }
        public string OrganizedMarketLkpCode
        {
            get { return this.organizedMarketLkpCode; }
            set { this.organizedMarketLkpCode = value; }
        }
        public override bool Equals(object obj)
        {
            return base.Equals(obj);
        }
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            ................
            return sb.ToString();
        }
        public bool IsNullEntity
        {
            get
            {
                if (this.financialEntityIdentifier == null ||
this.customerGIdentifier == null)
                    return true;
                else
                {
                   if (financialEntityIdentifier.Key == null ||
customerGIdentifier.Key == null)
                        return true;
                    else
                        return false;
                }
            }
        }
    }
}

Y la clase PrimaryKey:

namespace CustomerDataORM.Server.DataAccess
{
    public class PrimaryKey<T>
    {
        private T oldKey;
        private T mKey;

        public PrimaryKey(T key)
        {
            this.mKey = key;
            this.oldKey = key;
        }

        public T Key
        {
            get
            {
                return mKey;
            }
            set
            {
                mKey = value;
            }
        }

        public T OldKey
        {
            get
            {
                return oldKey;
            }
            set
            {
                oldKey = value;
            }
        }
    }
}





On 8 feb, 14:13, "Ica" <[EMAIL PROTECTED]> wrote:
> Buenas, puede que me haya expresado mal, son 3 campos que componen la
> clave primaria.
>
> Echaré un vistazo al hilo que comentas.
>
> Gracias.
>
> Un saludo.
>
> On 8 feb, 14:00, Fabio Maulo <[EMAIL PROTECTED]> wrote:
>
>
>
> > Mas que complejo me parece muy confuso.
> > Vamos de a poco..... (entre linea)
>
> > Ica escribió:> Tengo una clase genérica para representar mis claves, pero 
> > no se cómo
> > > ponerlo en el fichero de mapeo.
>
> > > Un pequeño ejemplo del código:
>
> > > public class ClavePrimaria<T>
> > > {
> > >      private T claveActual;
> > >      private T claveAntigua;
>
> > >      public ClavePrimaria(T clave)
> > >      {.....}
> > >      .........
> > > }
>
> > El hecho de tener "claveActual" y "claveAntigua" es el clásico ejemplo
> > que demuestra que la PK no se debe involucrar con informaciones del negocio.
> > ya que parece que estas haciendo una conversión, conviertete al uso de
> > PK sin significado alguno para el negocio. Si quieres leer algo fijate
> > el thread "Obviar composite-keys" del 14/12/2006 hay un mail con un
> > adjunto; lee el adjunto.
>
> > Este enjendro acá abajo que significa? son 3 campos que componen la
> > clave primaria o son 3 claves primarias?
> > Como sería rarisimo que sean 3 claves primarias por favor hace un
> > ejemplo real.> public class Entidad1
> > > {
> > >      private ClavePrimaria<string> id_1;
> > >      private ClavePrimaria<int> id_2;
> > >      private ClavePrimaria<DateTime?> id_3;
>
> > >      ................
> > > }
>
> > Bye.
> > Fabio.- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -


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

Responder a