Browse Source

Add clarity around repositories

David Ginzberg 7 years ago
parent
commit
c142d04305
1 changed files with 3 additions and 1 deletions
  1. 3
    1
      README.md

+ 3
- 1
README.md View File

122
  
122
  
123
 In this section we're going to re-create our service class using JPA. 
123
 In this section we're going to re-create our service class using JPA. 
124
 
124
 
125
-Start by breaking your `PersonService` class into an interface and implementation eg: `interface PersonService` and `class jdbcPersonServiceImpl`. Place the `@Service` annotation on the implementation class.
125
+Start by breaking your `PersonService` class into an interface and implementation eg: `interface PersonService` and `class JdbcPersonServiceImpl`. Place the `@Service` annotation on the implementation class.
126
 
126
 
127
 Now create a new class that implements the PersonService, this time with JPA. Once you annotate this class with @Service you will get an error when you start spring -- you can fix this by annotation the service you want to use with `@Primary` -- This tells Spring that if there are multiple beans competing for autowiring, the one marked with `@Primary` should be used (this won't work if multiple competing beans are marked `@Primary`
127
 Now create a new class that implements the PersonService, this time with JPA. Once you annotate this class with @Service you will get an error when you start spring -- you can fix this by annotation the service you want to use with `@Primary` -- This tells Spring that if there are multiple beans competing for autowiring, the one marked with `@Primary` should be used (this won't work if multiple competing beans are marked `@Primary`
128
 
128
 
129
+In your `JdbcPersonServiceImpl` you used a `JdbcTemplate` or `NamedParameterJdbcTemplate` to access the database. In your `JpaPersonServiceImpl` you will use a `PersonRepository` instead. You will have to define the interface for this repository, but the Spring Framework will provide the implementation automatically.
130
+
129
 Implement all of the methods found in your `PersonService` interface in this new JPA-based service. You won't have to change your controller at all if you are autowiring a reference to a `PersonService` - Spring will automatically inject the `@Primary`-annotated implementation of `PersonService`
131
 Implement all of the methods found in your `PersonService` interface in this new JPA-based service. You won't have to change your controller at all if you are autowiring a reference to a `PersonService` - Spring will automatically inject the `@Primary`-annotated implementation of `PersonService`
130
 
132
 
131
 Remember that you won't be using the Jdbc service or any `JdbcTemplate` objects in this part of the lab.
133
 Remember that you won't be using the Jdbc service or any `JdbcTemplate` objects in this part of the lab.