1 Reply Latest reply on May 1, 2012 2:59 PM by james_sutherland

    Case statements in JPQL

    933936
      Hi,

      Is it possible in JPA ?

      sum(case 'condition1' and 'condition2' then 1 else 0)


      Thank you,
      Kavitha.
        • 1. Re: Case statements in JPQL
          james_sutherland
          Yes, JPQL supports CASE.

          See,
          http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/JPQL#Functions

          I'm not certain if the JPA 2.0 JPQL BNF supports functions inside a SUM, but it should work with TopLink/EclipseLink either way, as long as you are on a recent version.