Any drawbacks of using Hibernate EntityManager (vs. Hibernate Core)?

前端 未结 4 852
借酒劲吻你
借酒劲吻你 2020-12-31 05:35

The Hibernate EntityManager documentation states, that:

You may use a combination of all three together, annotations without JPA programming inter

4条回答
  •  醉话见心
    2020-12-31 05:49

    It has been clear: depending on the business and technical needs of your project

    But would I have any advantages when using purely Hibernate Core ?

    Do not forget both Hibernate Annotations and Hibernate EntityManager is built on top of Hibernate core. So one more layer. Besides That, it rely on its mapping metadata stored in XML files. Some users prefer To use XML files instead of annotations because it leaves the domain objects completely independent of the DAO implementation you choose. But when using annotations, Hibernate with JPA book is clear

    reduce your lines of code for mapping metadata, compared to the native XML files, and you may like the better refactoring capabilities of annotations

    JDBC >> Hibernate core >> Hibernate Annotations
    

    ...

    JDBC >> Hibernate core >> Hibernate EntityManager
    

    And JPA 2 fits better what JPA 1 has not been provided. A lot of new features is now available such as

    • Object oriented query API
    • Wrapper's @Embeddable
    • Collection of @Embeddables @ElementCollection

    And so on...

    Do not forget JPA EntityManager allows you retrieve its underlying vendor-specific provider by using getDelegate method if you need features where JPA does not provide.

提交回复
热议问题