Skip to content

Commit 4857675

Browse files
committed
BAEL-1319 Quick Guide on Data.sql and Schema.sql Files in Spring
1 parent 7b4d644 commit 4857675

4 files changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package org.baeldung.sqlfiles;
2+
3+
import static javax.persistence.GenerationType.IDENTITY;
4+
5+
import javax.persistence.Column;
6+
import javax.persistence.Entity;
7+
import javax.persistence.GeneratedValue;
8+
import javax.persistence.Id;
9+
10+
@Entity
11+
public class Country {
12+
13+
@Id
14+
@GeneratedValue(strategy = IDENTITY)
15+
private Integer id;
16+
17+
@Column(nullable = false)
18+
private String name;
19+
20+
public Integer getId() {
21+
return id;
22+
}
23+
public void setId(Integer id) {
24+
this.id = id;
25+
}
26+
public String getName() {
27+
return name;
28+
}
29+
public void setName(String name) {
30+
this.name = name;
31+
}
32+
33+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
INSERT INTO country (name) VALUES ('India');
2+
INSERT INTO country (name) VALUES ('Brazil');
3+
INSERT INTO country (name) VALUES ('USA');
4+
INSERT INTO country (name) VALUES ('Italy');
5+
COMMIT;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CREATE TABLE country (
2+
id INTEGER NOT NULL AUTO_INCREMENT,
3+
name VARCHAR(128) NOT NULL,
4+
PRIMARY KEY (id)
5+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
spring.jpa.hibernate.ddl-auto=none

0 commit comments

Comments
 (0)