1 Reply Latest reply: May 1, 2012 9:59 AM by JamesSutherland RSS

    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
          JamesSutherland
          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.