y la necesitas en el mapping ? 2010/2/24 Sebastian Iglesias (Gmail) <[email protected]>
> Si justamente no quiero una asociacion bidireccional, por eso es que no > tengo la propiedad Autoriza :) > > > > El 24 de febrero de 2010 12:14, Roberto Ramírez > <[email protected]>escribió: > > En tu hbm.xml para CFacturaAutoriza tienes una propiedad que no existe en >> la clase. >> -- >> Roberto Ramírez >> >> On Tue, Feb 23, 2010 at 12:06 PM, Sebastian <[email protected]> wrote: >> >>> Hola grupo >>> >>> Buneo este es mi primero mensaje, el problema que tengo es en el mapeo >>> de una factura a sus autorizaciones. La relacion es que tengo una >>> factura con un detalle de aurorizaciones, es una relacion >>> unidireccional de una factura hacia muchas autoirizaciones. >>> >>> El error que me da al pedir la coneccion es el siguiente: >>> >>> "Could not find a getter for property 'Autoriza' in class >>> 'PruebaCRUD_NH_IDCompuesto.CFacturaAutoriza" >>> >>> Mi solucion de prueba tiene las siguentes clases. >>> >>> public class CFacturaAutoriza >>> { >>> private int? _oldHashCode; >>> public override bool Equals(object obj) >>> { >>> CFacturaAutoriza other = obj as CFacturaAutoriza; >>> if (other == null) >>> return false; >>> >>> // handle the case of comparing two NEW objects >>> bool otherIsTransient = Equals(other.Numero, -1); >>> bool thisIsTransient = Equals(Numero, -1); >>> >>> if (otherIsTransient && thisIsTransient) >>> return ReferenceEquals(other, this); >>> return other.Numero.Equals(this.Numero) && >>> other.Fecha.Equals(this.Fecha) && other.Tipodoc.Equals(this.Tipodoc) >>> && other.Posicion.Equals(this.Posicion); >>> } >>> >>> public override int GetHashCode() >>> { >>> // Once we have a hash code we'll never change it >>> if (_oldHashCode.HasValue) >>> return _oldHashCode.Value; >>> >>> bool thisIsTransient = Equals(Numero, -1); >>> // When this instance is transient, we use the base >>> GetHashCode() >>> // and remember it, so an instance can NEVER change its >>> hash code. >>> if (thisIsTransient) >>> { >>> _oldHashCode = base.GetHashCode(); >>> return _oldHashCode.Value; >>> } >>> return this.Numero.GetHashCode() + >>> this.Fecha.GetHashCode() + Tipodoc.GetHashCode() + >>> this.Posicion.GetHashCode(); >>> } >>> >>> public virtual DateTime Fecha { get; set; } >>> public virtual string Tipodoc { get; set; } >>> public virtual int Numero { get; set; } >>> public virtual int Posicion { get; set; } >>> public virtual string Descripcion { get; set; } >>> public virtual string Usuario { get; set; } >>> } >>> >>> public class CFacturaCabezal >>> { >>> >>> private int? _oldHashCode; >>> public override bool Equals(object obj) >>> { >>> CFacturaCabezal other = obj as CFacturaCabezal; >>> if (other == null) >>> return false; >>> >>> // handle the case of comparing two NEW objects >>> bool otherIsTransient = Equals(other.Numero, -1); >>> bool thisIsTransient = Equals(Numero, -1); >>> >>> if (otherIsTransient && thisIsTransient) >>> return ReferenceEquals(other, this); >>> return other.Fecha.Equals(this.Fecha) && >>> other.Tipodoc.Equals(this.Tipodoc) && >>> other.Numero.Equals(this.Numero); >>> } >>> >>> public override int GetHashCode() >>> { >>> // Once we have a hash code we'll never change it >>> if (_oldHashCode.HasValue) >>> return _oldHashCode.Value; >>> >>> bool thisIsTransient = Equals(Numero, -1); >>> // When this instance is transient, we use the base >>> GetHashCode() >>> // and remember it, so an instance can NEVER change its >>> hash code. >>> if (thisIsTransient) >>> { >>> _oldHashCode = base.GetHashCode(); >>> return _oldHashCode.Value; >>> } >>> return this.Fecha.GetHashCode() + >>> this.Tipodoc.GetHashCode() + this.Numero.GetHashCode(); >>> } >>> >>> // public int Id { get; set; } >>> //public virtual int id { get; set; } >>> public virtual DateTime Fecha { get;set; } >>> string _tipodoc; >>> public virtual string Tipodoc >>> { >>> get { return this._tipodoc.Trim(); } >>> set { this._tipodoc = value; } >>> } >>> public virtual int Numero { get; set; } >>> public virtual DateTime Fechaasto { get; set; } >>> public virtual string Lote { get; set; } >>> public virtual int Asiento { get; set; } >>> public virtual IList<CFacturaAutoriza> Autoriza { get; set; } >>> } >>> >>> Y los archivos de mapeo son los siguientes. >>> >>> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >>> assembly="PruebaCRUD-NH-IDCompuesto" >>> namespace="PruebaCRUD_NH_IDCompuesto"> >>> <class name="CFacturaAutoriza" table="facturas_autoriza"> >>> <composite-id> >>> <key-property name="Fecha" column="fecha" type="date" /> >>> <key-property name="Tipodoc" column="tipodoc" type="String" >>> length="6" /> >>> <key-property name="Numero" column="numero" type="int" /> >>> <key-property name="Posicion" column="posicion" type="int" /> >>> </composite-id> >>> >>> <many-to-one >>> name="Autoriza" >>> class="CFacturaAutoriza" >>> insert="false" >>> update="false" >>> not-null="true" cascade="all"> >>> >>> <column name="Fecha" /> >>> <column name="Tipodoc" /> >>> <column name="Numero" /> >>> <column name="Posicion" unique="true"/> >>> </many-to-one> >>> >>> <property name="Posicion" column="posicion" type="int" /> >>> <property name="Descripcion" type="string" column="descripcion" /> >>> <property name="Usuario" type="string" column="usuario"/> >>> </class> >>> </hibernate-mapping> >>> >>> >>> /// Y el mapping de la clase FacturaAutoriza >>> >>> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >>> assembly="PruebaCRUD-NH-IDCompuesto" >>> namespace="PruebaCRUD_NH_IDCompuesto"> >>> <class name="CFacturaCabezal" table="facturas_cabezal" > >>> <synchronize table="facturas_cabezal"/> >>> <synchronize table="facturas_autoriza"/> >>> >>> <composite-id > >>> <key-property name="Fecha" column="fecha" type="date" /> >>> <key-property name="Tipodoc" column="tipodoc" type="String" >>> length="6" /> >>> <key-property name="Numero" column="numero" type="int" /> >>> </composite-id> >>> >>> <bag name="Autoriza" >>> table="facturas_autoriza" >>> inverse="true" >>> cascade="all" >>> lazy="true" >>> fetch="subselect" generic="true" > >>> <key> >>> <column name="Fecha" /> >>> <column name="Tipodoc"/> >>> <column name="Numero" /> >>> </key> >>> <one-to-many class="CFacturaAutoriza" /> >>> </bag> >>> >>> <property name="Fechaasto" type="date" column="fechaasto" /> >>> <property name="Lote" type="string" column="lote" length="6" /> >>> <property name="Asiento" type="int" column="asiento" length="10" / >>> > >>> </class> >>> </hibernate-mapping> >>> >>> >>> Bueno desde ya muchas gracias... >>> Sebastian. >>> >>> -- >>> Para escribir al Grupo, hágalo a esta dirección: >>> [email protected] >>> Para más, visite: http://groups.google.com/group/NHibernate-Hispano >>> >> >> -- >> Para escribir al Grupo, hágalo a esta dirección: >> [email protected] >> Para más, visite: http://groups.google.com/group/NHibernate-Hispano >> > > > > -- > Saludos.. > > Sebastián Iglesias > Montevideo - Uruguay > Blog: http://isebitas.blogspot.com/ > > -- > Para escribir al Grupo, hágalo a esta dirección: > [email protected] > Para más, visite: http://groups.google.com/group/NHibernate-Hispano > -- Fabio Maulo -- Para escribir al Grupo, hágalo a esta dirección: [email protected] Para más, visite: http://groups.google.com/group/NHibernate-Hispano
