`

org.hibernate.QueryException: , expected in

阅读更多

 

 org.hibernate.QueryException: , expected in SELECT [SELECT NEW com.coscon.cbs.domain.result.settlement.SettlementCommissionSumDetailResult (companys.companyNameCn as companyNameCn,commCntr.containerSizeType as containerSizeType, companyChargeCode.settlementChargeCodeDescription as settlementChargeCodeDescription, commCntr.commissionCurrencyCode as commissionCurrencyCode ,commCntr.commissionAmount as commissionAmount, COUNT(1) as containerNumbers,SUM(commCntr.commissionAmount) as commissionAmounts) FROM com.coscon.cbs.domain.model.settlement.SettlementHead  settlementHead, com.coscon.cbs.domain.model.settlement.CommissionBill commBl, com.coscon.cbs.domain.model.settlement.SettlementAR settlementAR, com.coscon.cbs.domain.model.settlement.SettlementDocumentCommissionContainer commCntr, com.coscon.cbs.domain.model.master.Company companys, com.coscon.cbs.domain.model.master.CompanyChargeCode companyChargeCode WHERE commBl.billBasicUuid=:businessReferenceUuid AND commBl.companyCode =:companyCode AND commBl.commissionMode=:chargeCodeGroup AND commBl.commissionType=:chargeCode AND commBl.rateCurrencyCode=settlementAR.currencyCode AND commBl.actualFlag=:actualFlag AND settlementAR.settlementDocumentArItemUuid =:settlementDocumentArItemUuid AND settlementAR.currencyCode =:currencyCode AND settlementAR.settlementDocumentHeadUuid = settlementHead.settlementDocumentHeadUuid AND commBl.billBasicUuid = settlementHead.businessReferenceUuid AND commBl.companyCode =settlementHead.companyCode AND commBl.commissionMode=settlementAR.chargeCodeGroup AND commBl.commissionType=settlementAR.chargeCode AND commBl.companyCode = commCntr.companyCode AND commBl.commissionMode = commCntr.commissionMode AND commBl.agencyCode = commCntr.agencyCode AND commBl.billBasicUuid = commCntr.billBasicUuid AND companys.companyCode = commCntr.companyCode AND companyChargeCode.companyCode = commCntr.companyCode AND companyChargeCode.chargeCode = commCntr.commissionType GROUP BY ( companys.companyNameCn,commCntr.containerSizeType,companyChargeCode.settlementChargeCodeDescription, commCntr.commissionCurrencyCode,commCntr.commissionAmount)]

            at org.hibernate.hql.classic.SelectParser.token(SelectParser.java:203)
            at org.hibernate.hql.classic.ClauseParser.token(ClauseParser.java:109)
            at org.hibernate.hql.classic.ClauseParser.end(ClauseParser.java:136)

出现这种情况跟你使用的hibernate 版本的解析器有关.. 

 

还有就是跟你使用的方式有关.. .. map 的方式 定制结果集的方式.. 进行的话,相对来说.map 的方式是最快的.. 但是有时候,我们的框架中定义死了. 如在weblogic中部署的问题  ,中文问题 等等.. 会将hibernate的解析器换成较低的版本

 

 

org.hibernate.QueryException:ClassNotFoundException:org.hibernate.hql.ast.HqlToken错误之解决办法 
org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken

解决办法:

Hibernate.hbm.xml中加入加入属性:

<property name="hibernate.query.factory_class">
        org.hibernate.hql.classic.ClassicQueryTranslatorFactory
</property>


原因
Hibernate3.0
采用新的基于ANTLRHQL/SQL查询翻译器,在Hibernate的配置文件中,hibernate.query.factory_class属性用来选择查询翻译

器。 
1)选择Hibernate3.0的查询翻译器: 
hibernate.query.factory_class= org.hibernate.hql.ast.ASTQueryTranslatorFactory 
2)选择Hibernate2.1的查询翻译器 
hibernate.query.factory_class= org.hibernate.hql.classic.ClassicQueryTranslatorFactory 
为了使用3.0的批量更新和删除功能,只能选择(1)否则不能解释批量更新的语句,当使用的时候出现了不支持条件输入中文的情况。选择(2

)可以支持输入中文,但没法解释批量更新语句了 
hibernate3中需要用到antlr,然而这个包在weblogic.jar中已经包含了antrl类库,就会产生一些类加载的错误,无法找到在war或者ear

hibernate3.jar 
出现这个错误之后,antlr会调用System.exit(),这样weblogic就会中止服务。 
解决方法
1.
是在hibernate.properties文件中增加属性:hibernate.query.factory_class,属性的值是

org.hibernate.hql.classic.ClassicQueryTranslatorFactory,这样就可以解决问题了。 
但是部分功能会有问题,譬如 
但本系在批量删除和更新会有问题,本系统不采用 
2.
antlr-2.7.5H3.jarWeblogicpre_Classpath :WinRarWinzip打开C:\bea\weblogic81\server\lib\weblogic.jar 删除里面的antlr

目录, 然后再antlr-2.7.5H3.jar放在weblogic.jar的同一目录(:替换之后没做做过严格测试,尚不知是否有后遗症
3. 1
、拷贝Hibernate3里带的包antlr-2.7.5H3.jar%WL_HOME%\server\lib 
2
、修改% mydomain% \ startWebLogic.cmd  
set CLASSPATH之前加上下面一句: 
set PRE_CLASSPATH=%WL_HOME%\server\lib\antlr-2.7.5H3.jar; 
set CLASSPATH之后加上下面一句: 
set CLASSPATH=%PRE_CLASSPATH%;%CLASSPATH% 
一切OK

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics