-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: NHibernate.QueryException: in expected:
PostPosted: Mon Jul 07, 2008 11:16 am 
Newbie

Joined: Mon Jul 07, 2008 10:55 am
Posts: 4
Hi All,

I am getting the error NHibernate.QueryException: in expected:
when i try to map my class using nHibernate.

NHibernate.QueryException: in expected: pReg [select pReg from PartyRegistry pReg where pReg.PartyId = ?].

this is my .hbm class

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="~~~~~~~~~~~~~~~~~"
namespace="~~~~~~~~~~~~~~~~">
<class name="PartyRegistry" table="~~~~~~~~~~~~~~">
<id name="PartyId" column="Party_PartyId_Patient" type="Int32">
<generator class="foreign">
<param name="property">Party</param>
</generator>
</id>
<many-to-one name="Party" class="~~~~~~~~~~~~.Party" constrained="true" />
</class>
</hibernate-mapping>

-----------------
and my entity class is:

public class ABC : EntityBase
{
public virtual Int32 PartyId { get; set; }


public static ABC GetResultForPartyId(IPersistenceService persistenceService, Int32 partyId)
{

ISession session = persistenceService.Session as ISession;
return (ABC)session.CreateQuery(" from ABC pReg where pReg.PartyId = ?").SetInt32(0, partyId).UniqueResult<ABC>();

}

}

_________________
regards
John


Top
 Profile  
 
 Post subject: NHibernate.QueryException: in expected:
PostPosted: Mon Jul 07, 2008 1:18 pm 
Newbie

Joined: Mon Jul 07, 2008 10:55 am
Posts: 4
i found out the solution :)

Mark the Nhibernate mapping file (*.hbm.xml) as Embedded Resource. right Click on mapping file .. take properties and change BuildAction to Embedded Resource .

_________________
regards
John


Top
 Profile  
 
 Post subject: Re: NHibernate.QueryException: in expected:
PostPosted: Tue Jul 07, 2009 3:00 pm 
Newbie

Joined: Tue Jul 07, 2009 2:48 pm
Posts: 1
For those facing the same problem ("NHibernate.QueryException: in expected: ..."), it might be helpful to check the configuration files to see if the assembly in which the the mapping file exists (a.k.a. *.hbm.xml marked as Embedded Resource) is listed. Example:

<object id="SessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate20">
<property name="MappingAssemblies">
<list>

<value>AssemblyNamespace.AssemblyName</value>
</list>
</property>
</object>


Regards,
Rafael Salmon


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.