title: How to Use CASE, WHEN in JPA
body: <p>I'm new to JPA and have the below JPA query:</p>
  
  <pre><code>String qry = " SELECT e from Event e"
                      + " WHERE e.meeting.meetingDate= :pdate"
                      + " AND e.meeting.feedId IN (1,2)"
                      + " AND e.status &lt;&gt; 'W'"
                      + " AND e.meeting.status ='A'"
                      + " AND e.settleStatus is NULL"
                      + " AND e.offTime is NULL"
                      + " AND e.eventCode &gt;'07:45:00'"
                      + " group by e.id";
  </code></pre>
  
  <p>And I need to add the <strong>ORDER BY</strong> clause dynamically. I use MySQL and please anybody tell me how to add below condition to my query using <strong>JPA</strong>.</p>
  
  <p><br>part to add:</p>
  
  <pre><code>ORDER BY
   CASE  WHEN m.country_code ='AU' THEN  e.timestamp_updated               
         WHEN m.country_code &lt;&gt; 'AU' THEN  e.event_code  
  END DESC  
  </code></pre>
  
  <p>how to add this query segment in to my JPA query?</p>