title: Datetime expression in JPA by passing as parameter
body: <p>I want to compare a datetime function in the JPA. Just wondering how to pass it. By the way I am very new to JPA. My input date will look like this <code>28/12/2014 16:20</code> and I am parsing it as date</p>
  
  <p>I have to pass this as a parameter but the database table (MS SQL) consists of datetime format as <code>2014-12-28 16:20:38.107</code> </p>
  
  <p>Here is my code.</p>
  
  <p>Under <code>@Entity</code> (I cannot edit this code since I don't have permissions to do so. Anyway other methods are accessing this entities, I am just reusing it)</p>
  
  <pre><code>    @Column(name = "PublishDate", nullable = false)
      private Date publishDate;
  </code></pre>
  
  <p>My Actual Code</p>
  
  <pre><code>    Date date = simpleDateFormat.parse(s);
      Message.findByPublishDate(date);
  </code></pre>
  
  <p>After running the above code with <code>Debug=true</code> I have seen the passed parameter in the sql query as:
  <code>messages0_.PublishDate=?</code> that means it's not even taking the date and I get the below exception</p>
  
  <pre><code>select operations0_.OperationsMessageID as Operatio1_10_, operations0_.Content as Content2_10_, 
  operations0_.CreatedDate as CreatedD3_10_, operations0_.ExpiryDate as ExpiryDa4_10_, 
  operations0_.PublishDate as PublishD5_10_, operations0_.Status as Status6_10_, operations0_.Title 
  as Title7_10_, operations0_.OperationsMessageTypeID as Operatio8_10_ from OperationsMessage 
  operations0_ where operations0_.PublishDate=?
  </code></pre>
  
  <p>Exception Details:</p>
  
  <pre><code>org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
  at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:172)
  at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:155)
  at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:417)
  at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
  at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
  at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
  at org.springframework.data.jpa.repository.support.LockModeRepositoryPostProcessor$LockModePopulatingMethodIntercceptor.invoke(LockModeRepositoryPostProcessor.java:105)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
  at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
  at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
  at com.sun.proxy.$Proxy44.findByPublishDate(Unknown Source)
  </code></pre>