title: JPQL query with CURRENT_DATE - 1 does not work
body: <p>I am new to <code>JPA2.0</code> and <code>Spring Data JPA</code> where in I am trying to get the details <code>where createdDt &gt; Sysdate and createdDt &gt; sysdate-1</code>. I am not sure if sysdate-1 can be achieved using CURRENT_DATE-1 function, its not working.</p>
  
  <p>Any help as below options doesn't works well? I also tried <code>YESTERDAY</code>, this also fails.</p>
  
  <p><strong>Here I am not looking to developed using PersistanceContext and entity Manager query.</strong></p>
  
  <pre><code>@Query("SELECT e FROM CustMstr e WHERE e.crteDt &lt; CURRENT_DATE AND (DAYS(e.crteDt) &gt; DAYS(CURRENT_DATE) - 1) AND e.accActive ='Y'")
  List&lt;CustMstr&gt; findByEmailAndAcc();
  </code></pre>
  
  <p>another way</p>
  
  <pre><code>@Query("SELECT e FROM CustMstr e WHERE e.crteDt &lt; CURRENT_DATE AND (DAYS(e.crteDt) &gt; CURRENT_DATE - 1) AND e.accActive ='Y'")
  List&lt;CustMstr&gt; findByEmailAndAcc();
  </code></pre>
  
  <p>Error below</p>
  
  <pre><code>Exception in thread "main" org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'exampleClient': Unsatisfied dependency expressed through field 'CustMstrRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'CustMstrRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.XX.XX.repository.CustMstrRepository.findByEmailAndAcc()!
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:581)
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:367)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1340)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
      at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:756)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:144)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:85)
      at com.XX.XX.app.ExampleMain.main(ExampleMain.java:10)
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'CustMstrRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.XX.XX.repository.CustMstrRepository.findByEmailAndAcc()!
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1704)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
      at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
      at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1133)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1060)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:578)
      ... 15 more
  Caused by: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: 
  Exception Description: Syntax error parsing [SELECT e FROM CustMstr e WHERE e.crteDt &lt; CURRENT_DATE AND (DAYS(e.crteDt) &gt; DAYS(CURRENT_DATE) - 1) AND e.acc_active ='Y']. 
  [62, 103] The right expression is not a valid expression.
      at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1616)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:350)
      at com.sun.proxy.$Proxy22.createQuery(Unknown Source)
      at org.springframework.data.jpa.repository.query.SimpleJpaQuery.validateQuery(SimpleJpaQuery.java:87)
      ... 54 more
  </code></pre>