Hola a todos! Tengo un problema con una excepcion que me tira, al
tratar de hacer un SELECT.

Les copio los archivos de mapeo y objetos.


//OBJETOS

namespace Ausentismo.ClasesDelDominio
{
    class Novedades
    {
        public Novedades()
        {

        }

        protected Novedades_Id id;

        public virtual Novedades_Id Id
        {
            get { return id; }
            set { id = value; }
        }


        private Licencias licencia;

        public virtual Licencias Licencia
        {
            get { return licencia; }
            set { licencia = value; }
        }

        protected Empleados empleado;

        public virtual Empleados Empleado
        {
            get { return empleado; }
            set { empleado = value; }
        }



        protected int contador;

        public virtual int Contador
        {
            get { return contador; }
            set { contador = value; }
        }

        protected DateTime fecha_hasta;

        public virtual DateTime Fecha_hasta
        {
            get { return fecha_hasta; }
            set { fecha_hasta = value; }
        }


        protected int cant_dias;

        public virtual int Cant_dias
        {
            get { return cant_dias; }
            set { cant_dias = value; }
        }

        protected string justificada;

        public virtual string Justificada
        {
            get { return justificada; }
            set { justificada = value; }
        }

        protected string usuario_alta;

        public virtual string Usuario_alta
        {
            get { return usuario_alta; }
            set { usuario_alta = value; }
        }

        protected DateTime fecha_alta;

        public virtual DateTime Fecha_alta
        {
            get { return fecha_alta; }
            set { fecha_alta = value; }
        }

        protected string usuario_modif;

        public virtual string Usuario_modif
        {
            get { return usuario_modif; }
            set { usuario_modif = value; }
        }

        protected DateTime fecha_modif;

        public virtual DateTime Fecha_modif
        {
            get { return fecha_modif; }
            set { fecha_modif = value; }
        }

        protected int anio;

        public virtual int Anio
        {
            get { return anio; }
            set { anio = value; }
        }

    }


namespace Ausentismo.ClasesDelDominio.IDs
{
    class Novedades_Id: ISerializable
    {
        public Novedades_Id()
        {

        }

        private Empleados empleado;

        protected virtual Empleados Empleado
        {
            get { return empleado; }
            set { empleado = value; }
        }

        private Licencias licencia;

        protected virtual Licencias Licencia
        {
            get { return licencia; }
            set { licencia = value; }
        }

        protected DateTime fecha_desde;

        protected virtual DateTime Fecha_desde
        {
            get { return fecha_desde; }
            set { fecha_desde = value; }
        }

        // override object.Equals
        public override bool Equals(object obj)
        {

           if (obj == null || GetType() != obj.GetType())
            {
                return false;
            }
            // TODO: write your implementation of Equals() here.
            if ((this.Licencia == ((Novedades_Id)obj).Licencia) &&
this.Empleado==((Novedades_Id)obj).Empleado && this.fecha_desde
==((Novedades_Id)obj).fecha_desde)
                return true;
            else return false;

        }

        // override object.GetHashCode
        public override int GetHashCode()
        {
            // TODO: write your implementation of GetHashCode() here.
            int hash = 13;
            hash += (null == this.Empleado ? 0 :
this.Empleado.GetHashCode());
            hash += (null == this.Licencia ? 0 :
this.Licencia.GetHashCode());
            hash += (null == this.Fecha_desde ? 0 :
this.Fecha_desde.GetHashCode());

            return hash;

        }


        #region Miembros de ISerializable

        void ISerializable.GetObjectData(SerializationInfo info,
StreamingContext context)
        {
            throw new Exception("The method or operation is not
implemented.");
        }

        #endregion
    }

//ARCHIVO DE MAPEO

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                   assembly="Ausentismo"
                   namespace="Ausentismo.ClasesDelDominio">
  <class name="Novedades" table="T_NOVEDADES" schema="SOLIDARIDAD">
    <composite-id class="Ausentismo.ClasesDelDominio.IDs.Novedades_Id"
name="Id" unsaved-value="none">
      <key-many-to-one class="Licencias" name="Licencia" foreign-
key="FK_NOV_LIC" lazy="false">
        <column name="ID_LICENCIA" sql-type="number"/>
        <column name="CONTADOR_LIC" sql-type="number" />
      </key-many-to-one>
      <key-many-to-one class="Empleados" name="Empleado" foreign-
key="FK_EMPLEADO" lazy="false">
        <column name="NRO_EMPLEADO"/>
        <column name="CONTADOR"/>
      </key-many-to-one>
      <key-property name="Fecha_desde" column="FECHA_DESDE"
type="DateTime"/>
      </composite-id>
    <many-to-one class="Licencias" foreign-key="FK_NOV_LIC"
insert="false" update="false" lazy="false" name="Licencia">
      <column name="ID_LICENCIA"/>
      <column name="CONTADOR"/>
    </many-to-one>
    <many-to-one class="Empleados" foreign-key="FK_EMPLEADO"
insert="false" update="false" lazy="false" name="Empleado">
      <column name="NRO_EMPLEADO"/>
      <column name="CONTADOR"/>
    </many-to-one>
    <property name="Contador" column="CONTADOR" type="int"/>
    <property name="Fecha_hasta" column="FECHA_HASTA" type="DateTime"/
>
    <property name="Cant_dias" column="CANT_DIAS" type="int"/>
    <property name="Justificada" column="JUSTIFICADA" type="string"/>
    <property name="Fecha_alta" column="FECHA_ALTA" type="DateTime"/>
    <property name="Usuario_alta" column="USUARIO_ALTA" type="string"/
>
    <property name="Fecha_modif" column="FECHA_MODIF" type="DateTime"/
>
    <property name="Usuario_modif" column="USUARIO_MODIF"
type="string"/>
    <property name="Anio" column="ANIO" type="int"/>
  </class>
</hibernate-mapping>


//HQL

 public IList buscarNovedades(Empleados empleado, DateTime fechaDesde,
DateTime fechaHasta)
        {
            session = HibernateUtil.SessionFactory.OpenSession();

            ITransaction transaction = session.BeginTransaction();

            String sql = "from Novedades n where n.Id.Empleado
= :empleado ";
            //sql += " and n.Id.Fecha_desde between :fechaDesde
and :fechaHasta";
            IQuery q = session.CreateQuery(sql);
            q.SetParameter("empleado", empleado);
            q.SetDateTime("fechaDesde", fechaDesde);
            q.SetDateTime("fechaHasta", fechaHasta);
            IList listaMovimientos = q.List();

            session.Close();
            if (listaMovimientos.Count != 0)
                return listaMovimientos;
            else return null;
        }

        }
    }


La excepcion que tira es la siguiente: SqlNode's text did not
reference expected number of columns

Supongo el problema es con mi composite-id, pero no encuentro nada que
me ayude. Por favor!!! si alguien sabe algo, me vendria muy bien..
Gracias desde ya.

Erika

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

Responder a