I know that hibernate has recently changed its type system to 3.6. I think this now allows you to associate a Java class with a type (or UserType). For example, I use joda-time and have a pair of UserTypes that map LocalDate and LocalDateTime to the corresponding SQL types.
This works great when working with objects, but if I want to pass the joda type as an HQL parameter, hibernation gets confused, so I have to remember that every time I make a call, I have to specify the type.
query.setParameter( "now", new LocalDateTime(), Hibernate.custom( LocalDateTimeType.class ) );
I think that now at the configuration step Configuration / SessionFactory we can say that LocalDateTime → LocalDatetimeType, but I'm not sure how to do this. I found TypeResolver, but I had problems decrypting the method that I have to call to achieve this.
Or please correct me if this is not possible even when using the new type in version 3.6.
java types hibernate jodatime
Mike Q Jan 18 2018-11-18T00: 00Z
source share