Skip to content

Commit 366fd7e

Browse files
committed
Tutorial 4: Data opslaan in een in-memory SQL database
Nu we weten hoe we op een eenvoudige manier onze eigen API kunnen aanspreken, gaan we in deze tutorial kijken hoe we de data kunnen opslaan in een échte database.. https://tweakers.net/advertorials/onlinejavaacademy2/tutorial4/
1 parent ca17d68 commit 366fd7e

File tree

7 files changed

+91
-6
lines changed

7 files changed

+91
-6
lines changed

.idea/modules/tutorial_main.iml

Lines changed: 29 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules/tutorial_test.iml

Lines changed: 29 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ targetCompatibility = 1.8
3232

3333
dependencies {
3434
compile("org.springframework.boot:spring-boot-starter-web")
35+
compile("org.springframework.boot:spring-boot-starter-data-jpa")
36+
compile("com.h2database:h2")
37+
compile("org.springframework.boot:spring-boot-devtools")
38+
compile("org.flywaydb:flyway-core")
39+
40+
3541
}
3642

3743
task wrapper(type: Wrapper) {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
debug=true
2+
3+
flyway.locations=classpath:db/migration,classpath:db/fixtures
4+
5+
spring.datasource.name=testdb
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
spring.profiles.active=dev
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
INSERT INTO product (name, price) VALUES ('Macbook Air', 999.95), ('Magic Mouse', 69.95);
2+
INSERT INTO product_list (name) VALUES ('Boodschappen'), ('Tech');
3+
INSERT INTO product_list_products (lists_id, products_id) VALUES (1,1);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CREATE TABLE product (
2+
id BIGINT AUTO_INCREMENT,
3+
name VARCHAR(255) NOT NULL,
4+
price DECIMAL(10,2) NOT NULL,
5+
PRIMARY KEY (id)
6+
);
7+
8+
CREATE TABLE product_list (
9+
id BIGINT AUTO_INCREMENT,
10+
name VARCHAR(255) NOT NULL,
11+
PRIMARY KEY (id)
12+
);
13+
14+
CREATE TABLE product_list_products (
15+
lists_id BIGINT NOT NULL,
16+
products_id BIGINT NOT NULL,
17+
UNIQUE KEY (lists_id, products_id)
18+
);

0 commit comments

Comments
 (0)