Hi all,
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).
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.
This will fail
Query query = session.createQuery( hql );
query.setParameter( "now", new LocalDateTime() );
return query.list();
This will work (type explicitly set)
Query query = session.createQuery( hql );
query.setParameter( "now", new LocalDateTime(), Hibernate.custom( LocalDateTimeType.class ) );
return query.list();
This will also work (using java.util.Date)
Query query = session.createQuery( hql );
query.setParameter( "now", new Date() );
return query.list();
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?
Thanks.