java如何在hql中使用between子句
谁能说出请求中的问题是什么:
@Query( "SELECT new com.app.gsc.entities.ListeBI(lm.listeDeCriteres.designation,count(*) as totalNumber,lm.ficheDeMission.dateEtHeurDeDepart) from ListeDeControleDetailsMission lm where lm.boolDepart=false AND Year(lm.ficheDeMission.dateEtHeurDeDepart)=:year AND Month(lm.ficheDeMission.dateEtHeurDeDepart) >= Month(lm.ficheDeMission.dateEtHeurDeDepart)=:FromMonth AND Month(lm.ficheDeMission.dateEtHeurDeDepart) <= Month(lm.ficheDeMission.dateEtHeurDeDepart)=:ToMonth GROUP BY lm.listeDeCriteres.designation" )
List<ListeBI> getIncidentDepartByFromToMonth( @Param( "FromMonth" ) int FromMonth, @Param( "ToMonth" ) int ToMonth,
@Param( "year" ) int year );
错误消息:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: >= near line 1, column 322 [SELECT new com.app.gsc.entities.ListeBI(lm.listeDeCriteres.designation,count(*) as totalNumber,lm.ficheDeMission.dateEtHeurDeDepart) from com.app.gsc.entities.ListeDeControleDetailsMission lm where lm.boolDepart=false AND Year(lm.ficheDeMission.dateEtHeurDeDepart)=:year AND Month(lm.ficheDeMission.dateEtHeurDeDepart) >= Month(lm.ficheDeMission.dateEtHeurDeDepart)=:FromMonth AND Month(lm.ficheDeMission.dateEtHeurDeDepart) <= Month(lm.ficheDeMission.dateEtHeurDeDepart)=:ToMonth GROUP BY lm.listeDeCriteres.designation]
# 1 楼答案
必须是这一部分:
Month(lm.ficheDeMission.dateEtHeurDeDepart) >= Month(lm.ficheDeMission.dateEtHeurDeDepart)=:FromMonth
。我想说,你的三个比较有问题