Yesoda Sanka 5 lat temu
rodzic
commit
b89c272cbf

+ 6
- 5
src/main/java/io/zipcoder/persistenceapp/PersonController.java Wyświetl plik

@@ -39,6 +39,7 @@ public class PersonController  {
39 39
     }
40 40
 
41 41
     @RequestMapping(value = "/person", method = RequestMethod.GET)
42
+
42 43
     public ResponseEntity<Iterable  <PersonService > >getPersonList( ){
43 44
         Iterable<PersonService> person = personRepository .findAll();
44 45
 
@@ -48,11 +49,11 @@ public class PersonController  {
48 49
         return new ResponseEntity<>(personIterable  , HttpStatus.OK ) ;
49 50
     }
50 51
 
51
-//    @RequestMapping(value = "/person/{id}", method = RequestMethod.PUT)
52
-//    public  ResponseEntity<?> updatePerson(@RequestBody PersonService person,@PathVariable Integer id){
53
-//        PersonService  p=personRepository.save(person ) ;
54
-//        return new ResponseEntity<>(HttpStatus.OK);
55
-//    }
52
+    @RequestMapping(value = "/person/{id}", method = RequestMethod.PUT)
53
+    public  ResponseEntity<?> updatePerson(@RequestBody PersonService person,@PathVariable Integer id){
54
+        PersonService  p=personRepository.save(person ) ;
55
+        return new ResponseEntity<>(HttpStatus.OK);
56
+    }
56 57
     @RequestMapping(value = "/person{id}", method = RequestMethod.DELETE )
57 58
     public void deletePerson( @PathVariable Integer id){
58 59
         personRepository .delete(id);

+ 14
- 0
src/main/java/io/zipcoder/persistenceapp/PersonService.java Wyświetl plik

@@ -1,15 +1,29 @@
1 1
 package io.zipcoder.persistenceapp;
2 2
 
3
+import javax.persistence.*;
3 4
 import java.util.Date;
4 5
 
6
+
7
+@Entity
5 8
 public class PersonService {
9
+    @Id
10
+    @GeneratedValue (strategy= GenerationType.AUTO)
11
+            @Column(name="Id")
6 12
     Integer  ID;
13
+    @Column(name="FIRST_NAME")
7 14
     String FIRST_NAME;
15
+    @Column(name="LAST_NAME")
8 16
     String LAST_NAME;
17
+    @Column(name="MOBILE")
9 18
     String MOBILE;
19
+    @Column(name="BIRTHDAY")
10 20
     Date BIRTHDAY;
21
+    @Column(name="HOME_ID")
11 22
     int HOME_ID;
12 23
 
24
+    public PersonService() {
25
+    }
26
+
13 27
     public PersonService(Integer ID, String FIRST_NAME, String LAST_NAME, String MOBILE, Date BIRTHDAY, int HOME_ID) {
14 28
         this.ID = ID;
15 29
         this.FIRST_NAME = FIRST_NAME;

+ 1
- 1
src/main/resources/application-h2.properties Wyświetl plik

@@ -1,4 +1,4 @@
1
-spring.datasource.url=jdbc:h2:mem:testdb;Mode=Oracle
1
+spring.datasource.url=jdbc:h2:mem:test;Mode=Oracle
2 2
 spring.datasource.platform=h2
3 3
 spring.jpa.hibernate.ddl-auto=none
4 4
 spring.datasource.continue-on-error=true