title: Hibernate/Spring Data JPA is not able to identify WITHIN keyword in Spring Boot application
body: <p>I am using <code>@Formula</code> annotation for one of the property in my Entity/Pojo class. At runtime it is creating one query to fetch the result and it is throwing ERROR  <code>ORA-02000: missing WITHIN keyword</code> as it is not able to identify <code>WITHIN</code> as a keyword.</p>
  
  <p><strong>Marks.java</strong></p>
  
  <pre><code>@Formula("(SELECT CASE WHEN dis_order IS NULL THEN (SELECT listagg(qpm.displayed_order,', ') WITHIN GROUP (ORDER BY qpm.displayed_order) FROM que_post_mark qpm WHERE qpm.es_id = es_id AND qpm.sez_id = sez_id GROUP BY qpm.es_id, qpm.sez_id) ELSE NULL END FROM dual)")
  private String childItemsDisplayedOrder;
  </code></pre>
  
  <p>Generated Query is like below:</p>
  
  <pre><code>select marks0_.*,
  (SELECT
      CASE 
          WHEN marks0_.displayed_order IS NULL THEN (SELECT
              listagg(qpm.displayed_order,
              ', ') marks0_.WITHIN 
          GROUP (ORDER BY
              qpm.displayed_order) 
          FROM
              que_post_mark qpm 
          WHERE
              qpm.es_id  = marks0_.es_id  
              AND qpm.sez_id = marks0_.sez_id 
          GROUP BY
              qpm.es_id ,
              qpm.sez_id) 
          ELSE NULL 
      END 
  FROM
      dual) as formula2_0_ 
  from
      MARKS marks0_ 
  where
      marks0_.es_id =?
  </code></pre>
  
  <p>It is identifying <code>WITHIN</code> as column and appending alias name like <code>marks0_.WITHIN</code></p>
  
  <p>I am using below versions:</p>
  
  <pre><code> spring-boot-starter-web = 1.4.0.RELEASE, spring-data-jpa:jar:1.10.2 ,hibernate-entitymanager:jar:5.1.3' hibernate-core:jar:5.1.3, hibernate-jpa-2.1-api:jar
  </code></pre>
  
  <p>I tried to lower those jar versions to make it work but it didn't work.</p>
  
  <p>Error Stacktrace is like below:</p>
  
  <pre><code>Caused by: java.sql.SQLSyntaxErrorException: ORA-02000: missing WITHIN keyword
  
      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)
      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)
      at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1059)
      at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:522)
      at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:257)
      at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:587)
      at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:225)
      at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:53)
      at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:774)
      at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:925)
      at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1111)
      at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:4798)
      at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:4845)
      at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1501)
      at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:56)
      ... 136 common frames omitted
  </code></pre>
  
  <p>Could anyone help me to resolve this issue?</p>