Persisting Joda DateTime instead of Java Date in Hibernate

前端 未结 4 1770
一整个雨季
一整个雨季 2021-02-05 13:22

My entities currently contain java Date properties. I\'m starting to use Joda Time for date manipulation and calculations quite frequently. This means that I\'m constantly hav

4条回答
  •  情深已故
    2021-02-05 13:59

    So, to sum it up:

    java.util.Date

    • + native support in Hibernate
    • – bad API

    Joda-Time

    • + better API
    • – lack of native support in Hibernate

    Personally, if I could keep the domain model and "service layer" clean by just using a third party library (apparently User Type for Hibernate in this case) and the alternative would be to write some extra code to do the conversion "manually" every time it was needed, I'd go with the third party library.

提交回复
热议问题