2017-02-06 3 views
0

where節のcase文でいくつか問題があります。誰かがこれを修正する方法を知っている場合は、私を助けてください!ありがとうございました。 org.hibernate.hql.internal.ast.QuerySyntaxException: 予期しないASTノード:によって引き起こさどこの問題でのJPQLのケース文

:と近い行1、列589

@Query("select e from EventTeamPlayer etp " 
       + "join etp.event e " 
       + "left join e.leagueTournament lt " 
       + "left join lt.sportCategory sc " 
       + "left join e.sport s " 
       + "left join etp.homeTeamPlayer htpl " 
       + "left join etp.awayTeamPlayer atpl " 
       + "left join lt.country c " 
       + "left join e.eventStatus es " 
       + "where (e.startDate >= :startDate and e.startDate <= :endDate) " 
       + "and lt.id = :leagueTournamentId " 
       + "and (lt.defaultName like :searchTerm or " 
        + "s.name like :searchTerm or " 
        + "htpl.name like :searchTerm or " 
        + "atpl.name like :searchTerm or " 
        + "e.id like :searchTerm) and " 
        + "(case when (:minDate is not null and :maxDate is not null) " 
        + " then (e.startDate >=:minDate and e.startDate<=:maxDate) else true end) = true") 
    Page<Event> getEventsForWebAdmin(Pageable pageable, 
            @Param("searchTerm") String searchTerm, 
            @Param("leagueTournamentId") int leagueTournamentId, 
            @Param("startDate") Date startDate, 
            @Param("endDate") Date endDate, 
            @Param("minDate") Date minDate, 
            @Param("maxDate") Date maxDate); 

、ここでは、ログ内のエラーです【 com.itengine.bettinggateway.dao.EventTeamPlayer ETPから電子を選択etp.event Eに参加 は がe.sport左 ETPに参加左etp.homeTeamPlayer htplに参加だ参加左lt.sportCategory SCを結合左LT e.leagueTournamentに参加左.awayTeamPlayer atpl left join lt.country c left join e.eventStatus es(e.startDate> =:startDateおよびe.startDate < =:endDate)および (lt.defaultNameは次のようになります:searchTermまたはs.name like:searchTermまたは htpl.name (:minDateがnullでなく、maxDateが でない場合)then(e.startDate> =:minDateおよびe.startDate)検索の結果、 < =:maxDateの)他の 真のエンド)がtrue =とlt.id =:leagueTournamentId]

答えて

1

私はあなたがJPQL中の文のようなものを引き出すことができると思ういけません。

はこのようなものに置き換えることをお試しください:

AND 
(
    (:minDate is not null and :maxDate is not null 
     and e.startDate >=:minDate and e.startDate<=:maxDate) 
    OR 
    (:minDate is null or :maxDate is null)     
) 
1

あなたはJPQL API docsを見れば、それは言う:句を使用することができます

when_clause::= WHEN conditional_expression THEN scalar_expression

のでthen

scalar_expression ::= arithmetic_expression | string_primary | enum_primary | datetime_primary | boolean_primary | case_expression | entity_type_expression

あなたはthen節の中でこれを違反しています。 CASEをAND-ORの組み合わせに置き換えてください。

関連する問題