问题描述
HQL语句:selectcasewhenmaxemelent(sm.mcode)isnullthensubstring(concat('0','01'),1,length('0')+2)elsesubstring(concat('00',cast(cast(substring(maxemelent(sm.mcode),length('0'),length('0')+2)asint)+1asvarchar)),2,length('0')+2)endfromAppStaticMenusmwheresm.MParentCode=:MParentCode异常:Spring.Data.NHibernate.HibernateQueryException:couldnotresolveproperty:mcodeof:Model.AppStaticMenu[selectcasewhenmaxemelent(sm.mcode)isnullthensubstring(concat('0','01'),1,length('0')+2)elsesubstring(concat('00',cast(cast(substring(maxemelent(sm.mcode),length('0'),length('0')+2)asint)+1asvarchar)),2,length('0')+2)endfromAppStaticMenusmwheresm.MParentCode=:MParentCode]--->NHibernate.QueryException:couldnotresolveproperty:mcodeof:Model.AppStaticMenu[selectcasewhenmaxemelent(sm.mcode)isnullthensubstring(concat('0','01'),1,length('0')+2)elsesubstring(concat('00',cast(cast(substring(maxemelent(sm.mcode),length('0'),length('0')+2)asint)+1asvarchar)),2,length('0')+2)endfromAppStaticMenusmwheresm.MParentCode=:MParentCode]在NHibernate.Persister.Entity.AbstractPropertyMapping.ToType(StringpropertyName)在NHibernate.Persister.Entity.AbstractEntityPersister.ToType(StringpropertyName)在NHibernate.Hql.Ast.ANTLR.Tree.FromElementType.GetPropertyType(StringpropertyName,StringpropertyPath)在NHibernate.Hql.Ast.ANTLR.Tree.DotNode.GetDataType()在NHibernate.Hql.Ast.ANTLR.Tree.DotNode.PrepareLhs()在NHibernate.Hql.Ast.ANTLR.Tree.DotNode.ResolveInFunctionCall(BooleangenerateJoin,BooleanimplicitJoin)在NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.Resolve(IASTNodenode)在NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.expr()在NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.functionCall()在NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.expr()在NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.exprOrSubquery()在NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.comparisonExpr()在NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.logicalExpr()在NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.caseExpr()在NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.arithmeticExpr()在NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectExpr()在NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectExprList()在NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectClause()在NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.unionedQuery()在NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.query()在NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectStatement()在NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.statement()在NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate()在NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(IDictionary`2replacements,Booleanshallow,StringcollectionRole)在NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNodeast,StringqueryIdentifier,StringcollectionRole,Booleanshallow,IDictionary`2filters,ISessionFactoryImplementorfactory)在NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(StringqueryString,StringcollectionRole,Booleanshallow,IDictionary`2filters,ISessionFactoryImplementorfactory)在NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(StringqueryString,Booleanshallow,IDictionary`2enabledFilters)在NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(Stringquery,Booleanshallow)在NHibernate.Impl.AbstractSessionImpl.CreateQuery(StringqueryString)在Spring.Data.NHibernate.Generic.FindByNamedParamHibernateCallback`1.DoInHibernate(ISessionsession)在Spring.Data.NHibernate.Generic.HibernateTemplate.ExecuteFind[T](IFindHibernateCallback`1action,BooleanexposeNativeSession)---内部异常堆栈跟踪的结尾---在Spring.Data.NHibernate.Generic.HibernateTemplate.ExecuteFind[T](IFindHibernateCallback`1action,BooleanexposeNativeSession)在Spring.Data.NHibernate.Generic.HibernateTemplate.FindByNamedParam[T](StringqueryString,String[]paramNames,Object[]values,IType[]types)在Spring.Data.NHibernate.Generic.HibernateTemplate.FindByNamedParam[T](StringqueryName,StringparamName,Objectvalue,ITypetype)在Spring.Data.NHibernate.Generic.HibernateTemplate.FindByNamedParam[T](StringqueryName,StringparamName,Objectvalue)在DAO.AppStaticMenuDao.GetMaxId(Stringpcode)位置E:ProjectEXTMecProductCodeDAOApplicationAppStaticMenuDao.cs:行号14在Service.AppStaticMenuSrv.GetMaxId(Stringpcode)位置E:ProjectEXTMecProductCodeServiceApplicationAppStaticMenuSrv.cs:行号63在_dynamic_Service.AppStaticMenuSrv.GetMaxId(Object,Object[])在Spring.Reflection.Dynamic.SafeMethod.Invoke(Objecttarget,Object[]arguments)在Spring.Aop.Framework.DynamicMethodInvocation.InvokeJoinpoint()在Spring.Aop.Framework.AbstractMethodInvocation.Proceed()在Spring.Transaction.Interceptor.TransactionInterceptor.Invoke(IMethodInvocationinvocation)在Spring.Aop.Framework.AbstractMethodInvocation.Proceed()在Spring.Aop.Framework.DynamicProxy.AdvisedProxy.Invoke(Objectproxy,Objecttarget,TypetargetType,MethodInfotargetMethod,MethodInfoproxyMethod,Object[]args,IListinterceptors)在CompositionAopProxy_253cf8a6ef404f9e9c8736613efced26.GetMaxId(Stringpcode)在Web.View.Application.AppSMenu.AddMenu()位置E:ProjectEXTMecProductCodeWebViewApplicationAppMenuAppSMenu.aspx.cs:行号35
解决方案
解决方案二:
楼主,把你的这些SQL语句直接丢到DBMS的查询分析器里测试,比问我们强