Merge pull request #2992 from vitallan/BAEL-1319

BAEL-1319 Quick Guide on Data.sql and Schema.sql Files in Spring
This commit is contained in:
Carsten Gräf 2017-11-11 13:29:18 +01:00 committed by GitHub
commit 996bee2732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,33 @@
package org.baeldung.sqlfiles;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class Country {
@Id
@GeneratedValue(strategy = IDENTITY)
private Integer id;
@Column(nullable = false)
private String name;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -0,0 +1,5 @@
INSERT INTO country (name) VALUES ('India');
INSERT INTO country (name) VALUES ('Brazil');
INSERT INTO country (name) VALUES ('USA');
INSERT INTO country (name) VALUES ('Italy');
COMMIT;

View File

@ -0,0 +1,5 @@
CREATE TABLE country (
id INTEGER NOT NULL AUTO_INCREMENT,
name VARCHAR(128) NOT NULL,
PRIMARY KEY (id)
);

View File

@ -0,0 +1 @@
spring.jpa.hibernate.ddl-auto=none