问题
I was confident that Spring Data
and Spring Data JPA
refers as same, but then I watched a tutorial on youtube about Spring Data and he is using JdbcTemplate
in that tutorial. So I got confused there.
I want to clarify that what is difference between Spring Data
and JdbcTemplate
? JdbcTemplate
and Spring Data JPA
are parts of Spring Data
?
回答1:
JdbcTemplate is part of the Spring Framework itself.
Spring Data is the project which consists of multiple sub-projects where Spring Data JPA is one of those sub-projects. Spring Data and the sub projects build on top of the Spring Framework.
回答2:
Use Spring JdbcTemplate
if you don't want to access your database schema via a domain model. Using JPA you need to make sure that database schema maps correctly to the domain model.
Performance is almost similar at both spring JdbcTemplate
and JPA.
JPA is the Java Persistence API, which is Java's standard API for object-relational mapping.
The Spring Framework consists of a collection of projects, and one of these projects is Spring Data.
The goal of Spring Data is to make it easier to work with different kinds of databases, from traditional relational databases to NoSQL databases. Spring Data supports JPA via the Spring Data JPA subproject.
来源:https://stackoverflow.com/questions/52532319/spring-data-vs-spring-data-jpa-vs-jdbctemplate