高手求救:关于nhibernate联合主键的查找问题
HQL语句是这样写的:string hql = "from Userdeprole u where u.DepID = :depid";
我的映射文件是这样写的
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" schema="dbo">
<class name="ClassLibrary.Userdeprole,ClassLibrary" table="Userdeprole" lazy="false">
<composite-id>
<key-property name="UserID" column="USERID" type="string" length="36" />
<key-property name="DepID" column="DEPID" type="string" length="36" />
</composite-id>
<property name="RoleID" column="ROLEID" type="string" length="10" />
</class>
</hibernate-mapping>
错误信息应该是:in expected: u [from Userdeprole u where u.DepID = :depid]
堆栈跟踪:
[QueryException: in expected: u [from Userdeprole u where u.pk.DepID = :depid]]
NHibernate.Hql.Classic.FromParser.Token(String token, QueryTranslator q) +2400
NHibernate.Hql.Classic.ClauseParser.Token(String token, QueryTranslator q) +861
NHibernate.Hql.Classic.PreprocessingParser.Token(String token, QueryTranslator q) +689
NHibernate.Hql.Classic.ParserHelper.Parse(IParser p, String text, String seperators, QueryTranslator q) +155
NHibernate.Hql.Classic.QueryTranslator.Compile() +160
NHibernate.Hql.Classic.QueryTranslator.Compile(IDictionary replacements, Boolean scalar) +52
NHibernate.Impl.SessionFactoryImpl.GetQuery(String queryString, Boolean shallow, IDictionary enabledFilters) +135
NHibernate.Impl.SessionImpl.GetQueries(String query, Boolean scalar) +25
NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters, IList results) +122
NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters) +46
NHibernate.Impl.QueryImpl.List() +114
Modules_System_Department_Department_Edit.DeleteWithUser(String depID) in d:\KDWS\Modules\System\Department\Department_Edit.aspx.cs:107
Modules_System_Department_Department_Edit.Button2_Click(Object sender, EventArgs e) in d:\KDWS\Modules\System\Department\Department_Edit.aspx.cs:66
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
--------------------编程问答-------------------- 一般来说这个HQL是找不到Userdeprole这个对象,但是我查看我的xml,类名称都是一致的啊
我估计是错在HQL上,联合主键查找可能有特殊的格式,但我一直查不到,只有求高手求救了 --------------------编程问答-------------------- js框架 和 控件库
补充:.NET技术 , 分析与设计