Skip to content

Commit

Permalink
Ders 9
Browse files Browse the repository at this point in the history
H2 veritabanı çalışma şekilleri(hafıza, dosya, ağ), veritabanı nesnesinin değişmesi sonrası veritabanının 'hibernate' tarafından otomatik güncellenmesi
  • Loading branch information
srkns committed May 18, 2023
1 parent e2fe41c commit 79f69ee
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public Kisi kisiEkle(@RequestBody KisiDTO kisiDTO) {
kisi.setAd(kisiDTO.getAd());
kisi.setSoyad(kisiDTO.getSoyad());
kisi.setYas(kisiDTO.getYas());
kisi.setTelefon(kisiDTO.getTelefon());
kisi = kisiRepository.save(kisi);
return kisi;
}
Expand All @@ -51,6 +52,7 @@ public Kisi kisiGuncelle(@PathVariable Long id, @RequestBody KisiDTO kisiDTO) {
kisi.setAd(kisiDTO.getAd());
kisi.setSoyad(kisiDTO.getSoyad());
kisi.setYas(kisiDTO.getYas());
kisi.setTelefon(kisiDTO.getTelefon());
kisi = kisiRepository.save(kisi);
return kisi;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ public class KisiDTO {
private String ad;
private String soyad;
private int yas;
private String telefon;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ public class Kisi {
private String ad;
private String soyad;
private int yas;
private String telefon;

}
16 changes: 15 additions & 1 deletion restveri/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@

spring.datasource.url=jdbc:h2:mem:restveri
# H2 veritaban?n?n destekledi?i ba?lant? ?ekilleri:

# *Haf?zada çal???r:(uygulama kapand??? zaman veriler kaybolur)
#spring.datasource.url=jdbc:h2:mem:restveri

# *Dosya ile çal???r:
#spring.datasource.url=jdbc:h2:file:~/restveri

# *Ço?u veritaban?na benzer ?ekilde IP:PORT ba?lant?s? ile çal???r:(bu durumda bir H2 sunucusu çal???yor olmal?)
#spring.datasource.url=jdbc:h2:tcp://localhost:9092/~/restveri

spring.datasource.url=jdbc:h2:tcp://localhost:9092/~/restveri2
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=sa
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect

spring.h2.console.enabled=true
spring.h2.console.path=/h2

spring.jpa.hibernate.ddl-auto=update

0 comments on commit 79f69ee

Please sign in to comment.