|
|
|
|
68
|
- `GET` `/people/surname` -- Get the result of the surname report above
|
68
|
- `GET` `/people/surname` -- Get the result of the surname report above
|
69
|
- `GET` `/people/firstname/stats` -- Get the report of first name frequencies
|
69
|
- `GET` `/people/firstname/stats` -- Get the report of first name frequencies
|
70
|
|
70
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
#### Homes and People
|
71
|
#### Homes and People
|
75
|
There is another table in the data base named home that consist of the following
|
72
|
There is another table in the data base named home that consist of the following
|
76
|
fields:
|
73
|
fields:
|
|
|
|
|
94
|
_You may use the query in the 'data-h2.sql' file to populate the 'PERSON' and 'HOME' table_
|
91
|
_You may use the query in the 'data-h2.sql' file to populate the 'PERSON' and 'HOME' table_
|
95
|
|
92
|
|
96
|
|
93
|
|
97
|
-
|
|
|
98
|
Support the following operations:
|
94
|
Support the following operations:
|
|
|
95
|
+
|
99
|
- Add a "Home" to the database
|
96
|
- Add a "Home" to the database
|
100
|
- Add a person to a home
|
97
|
- Add a person to a home
|
101
|
- Update an existing 'Home' in the database
|
98
|
- Update an existing 'Home' in the database
|
102
|
- Remove a home from the database
|
99
|
- Remove a home from the database
|
103
|
- Remove a list of homes from the database
|
100
|
- Remove a list of homes from the database
|
104
|
- Find a home by id
|
101
|
- Find a home by id
|
105
|
-- Find a hom by home number
|
|
|
|
|
102
|
+- Find a home by home number
|
106
|
- Find a home by address
|
103
|
- Find a home by address
|
107
|
- Find a home by person id
|
104
|
- Find a home by person id
|
108
|
- Generate a list of people that live in a home
|
105
|
- Generate a list of people that live in a home
|
109
|
|
106
|
|
110
|
|
107
|
|
111
|
|
108
|
|
112
|
-
|
|
|
113
|
List all of the homes that have more that one person that live there. Group people by the home that they
|
109
|
List all of the homes that have more that one person that live there. Group people by the home that they
|
114
|
live in
|
110
|
live in
|
115
|
|
111
|
|
|
|
|
|
122
|
Find the home number of John Smith
|
118
|
Find the home number of John Smith
|
123
|
|
119
|
|
124
|
|
120
|
|
|
|
121
|
+## Part 3: JPA
|
|
|
122
|
+
|
|
|
123
|
+In this section we're going to re-create our service class using JPA.
|
|
|
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.
|
|
|
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`
|
125
|
|
128
|
|
|
|
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`
|
126
|
|
130
|
|
|
|
131
|
+Remember that you won't be using the Jdbc service or any `JdbcTemplate` objects in this part of the lab.
|