Spring data required hibernate or not

2020-03-24 09:29发布

问题:

I have one doubt about implementation of spring data, have basic knowledge about spring data. I understand JPA and Hibernate, how it work. Hibernate provide the implementation for JPA. My questions, Can we work alone with Spring data to persist data in mysql or we need some provider like hibernate or toplink etc for midsize application

回答1:

The structure is as follows:

Spring Data JPA
       |
      JPA
       |
   Hibernate

You need Hibernate as an JPA implementation, but from your perspective you should only see Spring Data JPA.

When designing your entities if you make sure that you use only annotations from the javax.persistence package you will not depend on one concrete JPA implementation (in this case Hibernate) but theoretically you could swap Hibernate for EclipseLink or something else.