Gracias Carlos, lo tendré en cuenta. Igualmente el problema estaba en que el 
archivo de mapeo hbm.xml no estaba como embebido. Cambie el valor de la 
propiedad y salio andando. Después tuve otros problemas pero los pude subsanar.
Mil gracias por tu tiempo y nuevamente disculpen porque tenia previsto 
contestar pero me colgué.
Saludos.
Javier.

From: [email protected]
Date: Fri, 16 Nov 2012 13:12:21 -0300
Subject: [puntonet] Problema en mapeo de NHibernate.
To: [email protected]

Javier,

Sin tener todos los mappings a la vista, creo que deberias escribir asi tu query

IQuery query = NHibernateSession.CreateQuery(
        "from Nombramiento as n where n.Persona.Id = :idPersona AND n.Active = 
1 Order by n.Id desc");



// Dependiendo del tipo de dato del ID
query.SetXXX("idPersona", idPersona);

----------------------------------
Carlos Peix

On Wed, Nov 14, 2012 at 5:31 PM, Javier Osvaldo Chércoles 
<[email protected]> wrote:





Gente tengo el esquema que le envió. 


Cuando quiero ejecutar:IQuery query = NHibernateSession.CreateQuery("select n 
from Nombramiento as n where n.persona = " + personaId.ToString() + " AND 
n.Active = 1 Order by n.Id desc");


Recibo el error:unexpected token: as [select n from Nombramiento as n where 
n.persona = nnnn AND n.Active = 1 Order by n.Id desc]


-NHibernateSession.CreateQuery("select n from Nombramiento as n where n.persona 
= " + personaId.ToString() + " AND n.Active = 1 Order by n.Id desc");   
'NHibernateSession.CreateQuery("select n from Nombramiento as n where n.persona 
= " + personaId.ToString() + " AND n.Active = 1 Order by n.Id desc")' produjo 
una excepción de tipo 'NHibernate.QueryException' NHibernate.IQuery 
{NHibernate.QueryException}



DB.CREATE TABLE [dbo].[Nombramiento](

        [Id] [int] IDENTITY(1,1) NOT NULL,      [personaId] [int] NOT NULL,     
[FechaDesde] [datetime] NOT NULL,

        [FechaHasta] [datetime] NOT NULL,       [Active] [bit] NOT NULL, 
CONSTRAINT [PK_Nombramiento] PRIMARY KEY CLUSTERED 

(       [Id] ASC)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, 
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON 
[PRIMARY]

) ON [PRIMARY]


Clase.

using System;using System.Collections.Generic;using System.Linq;using 
System.Text;
namespace PAC.Dominio{

    public class Nombramiento : DomainObject<int>, IReplicable    {        
private Persona _persona;        private DateTime _fechaHasta;        private 
DateTime _fechaDesde;

        private bool _active;
        public virtual Persona Persona        {            get { return 
_persona; }            set { _persona = value; }

        }
        public virtual DateTime FechaDesde        {            get { return 
_fechaDesde; }            set { _fechaDesde = value; }        }


        public virtual DateTime FechaHasta        {            get { return 
_fechaHasta; }            set { _fechaHasta = value; }        }


        public virtual bool Active        {            get { return _active; }  
          set { _active = value; }        }
        public override int GetHashCode()

        {            return (GetType().FullName + "|" +                
Persona.Nombre + "|" +                Id.ToString()).GetHashCode();        }


        #region IReplicable Members
        public int GetId()        {            return this.Id;        }
        public string GetNombreEntidad()

        {            return this.GetType().Name;        }        #endregion    
}}
XML de mapeo.

<?xml version="1.0" encoding="utf-8" ?><hibernate-mapping 
xmlns="urn:nhibernate-mapping-2.2">  <class name="PAC.Dominio.Nombramiento, 
PAC.Dominio" table="Nombramiento" lazy="false">

    <id name="Id" column="Id" unsaved-value="0">      <generator 
class="identity" />    </id>    <property name="FechaDesde" column="FechaDesde" 
/>

    <property name="FechaHasta" column="FechaHasta" />    <property 
name="Active"     column="Active" />        <!-- Persona -->

    <many-to-one name="Persona" column="personaId" class="PAC.Dominio.Persona, 
PAC.Dominio" ></many-to-one>
  </class></hibernate-mapping>


Gracias y disculpen.
Javier.
                                          

                                          

Responder a