similarity and difference between jpa and hibernate

前端 未结 4 2140
北恋
北恋 2020-12-05 19:28

what is similarity and difference between jpa and hibernate.

4条回答
  •  甜味超标
    2020-12-05 19:38

    As pointed out by @Pascal Hibernate existed prior to JPA standard(it is now JSR 317 JPA 2.0, which Hibernate has implemented in 3.5 already out for early use). So there are other providers of JPA e.g. Oracle TopLink, Apache OpenJPA. To use strictly JPA in Hibernate you have to use EntityManager as apposed to the Session which is a Hibernate concept pre-dating JPA. Similarly for strict JPA you have to use EntityManagerFactory as apposed to SessionFactory.

    The EntityManager and EntityManagerFactory are, in fact, thin wrappers around the Session and SessionFactory respectively. In addition, core/annotations Hibernate provide extensions to the JPA spec that make your life easier. Before JPA 2 Hibernate had a Criteria API which allowed you to programmatically construct a query in an OO fashion. JPA 2 now makes this functionality standard -- the JPA standard is a bit different from the Hibernate version as it employs generics. So basically the Hibernate functionality is a superset of JPA.

提交回复
热议问题