Hibernate TypeResolver

前端 未结 1 668
萌比男神i
萌比男神i 2020-12-17 15:29

I\'m aware that hibernate recently redid its type system in 3.6. I think this now allows you do associate a java Class with a Type (or UserType). For example I use joda-ti

1条回答
  •  天涯浪人
    2020-12-17 15:46

    Answering my own question.

    Simple enough when you know how.

    configuration.getTypeResolver().registerTypeOverride( LocalDateTimeType.TYPE, new String[]{ LocalDateTime.class.getName() } );
    configuration.getTypeResolver().registerTypeOverride( LocalDateType.TYPE, new String[]{ LocalDate.class.getName() } );
    

    The TypeResolver lookups for unknown types use the class name so registering the full name of the class as the registrationKey does the job.

    0 讨论(0)
提交回复
热议问题