Skip to content

Commit feba3e4

Browse files
committed
Remove EntityManager and rename controller
1 parent 477e3b3 commit feba3e4

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/main/java/com/kaluzny/web/BookRestController.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import org.springframework.web.bind.annotation.*;
88

99
import javax.inject.Inject;
10-
import javax.persistence.EntityManager;
11-
import javax.persistence.PersistenceContext;
1210
import java.util.Collection;
1311

1412
@RestController
@@ -17,9 +15,6 @@ public class BookRestController {
1715

1816
private BookRepository repository;
1917

20-
@PersistenceContext
21-
private EntityManager entityManager;
22-
2318
@Inject
2419
public void setRepository(BookRepository repository) {
2520
this.repository = repository;
@@ -38,15 +33,15 @@ public ResponseEntity<Collection<Book>> getAllBooks() {
3833
}
3934

4035
@RequestMapping(
41-
method = RequestMethod.GET,
42-
value = "/{id}")
36+
value = "/{id}",
37+
method = RequestMethod.GET)
4338
public ResponseEntity<Book> getBookWithId(@PathVariable Long id) {
4439
return new ResponseEntity<>(repository.findOne(id), HttpStatus.OK);
4540
}
4641

4742
@RequestMapping(
48-
method = RequestMethod.GET,
49-
params = {"name"})
43+
params = {"name"},
44+
method = RequestMethod.GET)
5045
public ResponseEntity<Collection<Book>> findBookWithName(@RequestParam(value = "name") String name) {
5146
return new ResponseEntity<>(repository.findByName(name), HttpStatus.OK);
5247
}
@@ -65,8 +60,8 @@ public ResponseEntity<Book> updateUserFromDB(@PathVariable("id") long id, @Reque
6560
}
6661

6762
@RequestMapping(
68-
method = RequestMethod.DELETE,
69-
value = "/{id}")
63+
value = "/{id}",
64+
method = RequestMethod.DELETE)
7065
public void deleteBookWithId(@PathVariable Long id) {
7166
repository.delete(id);
7267
}

0 commit comments

Comments
 (0)