Which are the differences/similarities between hibernate and other frameworks or specifications?

后端 未结 4 1839
情书的邮戳
情书的邮戳 2021-01-03 16:59

I want to know the differences/similarities between Hibernate and simple persistence in Java EE 5?

I\'m not clear if Hibernate implements Java EE 5 persistence imple

相关标签:
4条回答
  • 2021-01-03 17:24

    When JPA (Java EE 5 persistence standard) was developed by the JCP expert group (JSR 220) a lot of ideas have been taken from the existing Hibernate (also from JDO). Gavin King the founder of Hibernate himself has been part of the expert group among others.

    After the final JPA specification was published Hibernate became an open source implementation of it (since version 3.2). Hibernate still has a richer feature set and usually generates new features faster as an open-source development process tend to be faster then a Java community process.

    Other implementations of JPA are:

    • DataNucleus
    • EclipseLink
    • OpenJPA

    Other approaches are:

    • JDO
    • iBatis
    • plain JDBC
    0 讨论(0)
  • 2021-01-03 17:30

    Slightly off topic but JPA implies a "session orientated" architecture. That is your beans are attached/detached to an EntityManager and you persist/merge/flush the entityManager.

    If you are looking for a "sessionless" approach to ORM (no attached/detached persist/merge/flush) then you can also look at Ebean ORM which also uses JPA Annotations for mapping. You could also describe this as "Ebean provides automatic management of the Persistence Context".

    0 讨论(0)
  • 2021-01-03 17:33

    I want to know the differences/similarities between Hibernate and simple persistence in Java EE 5?

    The standardized persistence API of Java EE 5 is JPA 1.0 and is a kind of unified version of EJB 2 CMP, JDO, Hibernate, and TopLink APIs and products. Hibernate is an ORM framework that predates JPA and has heavily influenced the specification of JPA (the creator of Hibernate is a member of the expert group behind JPA). Just keep in mind that JPA is just an API, you need an implementation of JPA to use it.

    I'm not clear if Hibernate implements Java EE 5 persistence implementation or if it is a totally different approach to data representation over back-end systems.

    Yes, Hibernate provides an implementation of JPA (and also extends it, Hibernate is a superset of JPA) via the Hibernate EntityManager project (that relies on Hibernate Core).

    I'm confused about Hibernate and its relation with the concepts about java persistence given in the Java EE 5 tutorial... could you clarify the role of Hibernate in the context of Entities and EJBs?

    Hibernate can be used as the JPA persistence provider, i.e. as the piece of code that actually persists EJB 3 entities (the JPA specification was part of EJB 3.0 specification in version 1.0, it's now a separate spec)

    Also, I want to know other approaches (frameworks) like JPA or Spring...

    Spring is not a persistence framework, Spring is an IoC container, it doesn't compete with Hibernate.

    JPA compliant alternatives to Hibernate include TopLink Essentials (the RI in Java EE 5), EclipseLink (which is also the RI of JPA 2.0 in Java EE 6), OpenJPA, DataNucleus.

    Other options for persistence include JDO (another standardized persistence API), iBATIS (not an ORM, it's more a data mapper), JDBC (low level API) to cite the most famous.

    Check this previous answer for an overview and some historical background.

    0 讨论(0)
  • 2021-01-03 17:42

    The JPA specification described in EE5 is just an specification. This means that it is not a product. JPA is just a set of definitions that the different providers have to accomplish to be "JPA complaint"

    Hibernate is just another "plugable" persistence provider, this means that this product implements the definitions given by JPA specification. You can find other similar products like TopLink or Apache's OpenJPA.

    That is it.

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