title: Hibernate parameter typing with functions
body: <p>When using hibernate typically it can figure out the type of your parameters by looking at either the property it is against, or hibernate seems to recognise certain types by default (e.g. java.util.Date).</p>
  
  <p>However I have some queries which use functions (dateadd).  In these queries using a object that has a custom type binding fails (hibernate seems to default it to BINARY when it can't figure out the type).  I have to pass in the correct hibernate "Type" against the query parameter.</p>
  
  <p>This will fail</p>
  
  <pre><code>        Query query = session.createQuery( hql );
          query.setParameter( "now", new LocalDateTime() );
          return query.list();
  </code></pre>
  
  <p>This will work (type explicitly set)</p>
  
  <pre><code>        Query query = session.createQuery( hql );
          query.setParameter( "now", new LocalDateTime(), Hibernate.custom( LocalDateTimeType.class ) );
          return query.list();
  </code></pre>
  
  <p>This will also work (using java.util.Date)</p>
  
  <pre><code>        Query query = session.createQuery( hql );
          query.setParameter( "now", new Date() );
          return query.list();
  </code></pre>
  
  <p>Is there any way I can get Hibernate to recognise LocalDateTime as a type it can handle out of the box without having to remember to pass in the type explicitly each time?</p>
  
  <p>Thanks.</p>