What's the difference between JPA and Spring Data JPA?

后端 未结 3 1580
再見小時候
再見小時候 2020-12-12 08:22

I am a bit confused about the difference between Spring Data-JPA and JPA. I know about JPA that it is a specification for persisting the Java Objects to a relational databas

3条回答
  •  时光取名叫无心
    2020-12-12 09:16

    JPA

    JPA is a specification that standardizes the way Java Objects are mapped to a relational database system. Being just a specification, JPA consists of a set of interfaces, like EntityManagerFactory, EntityManager, and annotations that help you map a Java entity object to a database table.

    There are several JPA providers, like HIbernate, EclipseLink, or Open JPA which you can use.

    Spring Data JPA

    Spring Data JPA is a JPA data access abstraction. Just like JPA, Spring Data JPA cannot work without a JPA provider.

    Spring Data JPA offers a solution to the DDD Repository pattern or the DAO (Data Acess Object) pattern. It can also generate JPA queries on your behalf through method name conventions.

    Spring Data JPA can work with Hibernate, Eclipse Link, or any other JPA provider. A very interesting benefit of using Spring or Java EE is that you can control transaction boundaries declaratively using the @Transactional annotation.

提交回复
热议问题