如何在hql中使用between子句

时间:2016-11-02 16:21:49

标签: java spring spring-data

任何人都可以告诉我们请求中的问题:

 @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 );

ERROR消息:

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 个答案:

答案 0 :(得分:0)

必须是这部分:Month(lm.ficheDeMission.dateEtHeurDeDepart) >= Month(lm.ficheDeMission.dateEtHeurDeDepart)=:FromMonth。我想说你的3次比较存在问题。