Преглед изворни кода

Add clarity around repositories

David Ginzberg пре 7 година
родитељ
комит
c142d04305
1 измењених фајлова са 3 додато и 1 уклоњено
  1. 3
    1
      README.md

+ 3
- 1
README.md Прегледај датотеку

@@ -122,10 +122,12 @@ Find the home number of John Smith
122 122
  
123 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 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 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 133
 Remember that you won't be using the Jdbc service or any `JdbcTemplate` objects in this part of the lab.