Skip to content

Commit ba9d77d

Browse files
author
Rajeev Kumar Singh
committed
Upgraded to Spring Boot 2.0.0.RELEASE
1 parent c0cc0db commit ba9d77d

File tree

23 files changed

+32
-29
lines changed

23 files changed

+32
-29
lines changed

jpa-composite-primary-key-demo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>org.springframework.boot</groupId>
1616
<artifactId>spring-boot-starter-parent</artifactId>
17-
<version>1.5.8.RELEASE</version>
17+
<version>2.0.0.RELEASE</version>
1818
<relativePath/> <!-- lookup parent from repository -->
1919
</parent>
2020

jpa-composite-primary-key-demo/src/main/java/com/example/jpa/JpaCompositePrimaryKeyDemoApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void run(String... args) throws Exception {
3232
employeeRepository.save(employee);
3333

3434
// Retrieving an Employee Record with the composite primary key
35-
employeeRepository.findOne(new EmployeeIdentity("E-123", "D-457"));
35+
employeeRepository.findById(new EmployeeIdentity("E-123", "D-457"));
3636

3737
// Retrieving all the employees of a particular company
3838
employeeRepository.findByEmployeeIdentityCompanyId("D-457");

jpa-composite-primary-key-demo/src/main/java/com/example/jpa/model/Employee.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.example.jpa.model;
22

33
import org.hibernate.annotations.NaturalId;
4-
54
import javax.persistence.Column;
65
import javax.persistence.EmbeddedId;
76
import javax.persistence.Entity;
87
import javax.persistence.Table;
8+
import javax.validation.constraints.Email;
99
import javax.validation.constraints.NotNull;
1010
import javax.validation.constraints.Size;
1111

@@ -20,11 +20,13 @@ public class Employee {
2020
private EmployeeIdentity employeeIdentity;
2121

2222
@NotNull
23+
@Size(max = 60)
2324
private String name;
2425

25-
@NotNull
26-
@Size(max = 100)
2726
@NaturalId
27+
@NotNull
28+
@Email
29+
@Size(max = 60)
2830
private String email;
2931

3032
@Size(max = 15)

jpa-composite-primary-key-demo/src/main/java/com/example/jpa/model/EmployeeIdentity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import javax.persistence.Embeddable;
44
import javax.validation.constraints.NotNull;
5+
import javax.validation.constraints.Size;
56
import java.io.Serializable;
67

78
/**
@@ -10,9 +11,11 @@
1011
@Embeddable
1112
public class EmployeeIdentity implements Serializable {
1213
@NotNull
14+
@Size(max = 20)
1315
private String employeeId;
1416

1517
@NotNull
18+
@Size(max = 20)
1619
private String companyId;
1720

1821
public EmployeeIdentity() {

jpa-composite-primary-key-demo/src/main/resources/application.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
22
spring.datasource.url=jdbc:mysql://localhost:3306/jpa_composite_pk_demo?useSSL=false
33
spring.datasource.username=root
4-
spring.datasource.password=root
4+
spring.datasource.password=callicoder
55

66
# Hibernate
77

88
# The SQL dialect makes Hibernate generate better SQL for the chosen database
9-
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
9+
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
1010

1111
# Hibernate ddl auto (create, create-drop, validate, update)
1212
spring.jpa.hibernate.ddl-auto = update

jpa-element-collection-demo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>org.springframework.boot</groupId>
1616
<artifactId>spring-boot-starter-parent</artifactId>
17-
<version>1.5.8.RELEASE</version>
17+
<version>2.0.0.RELEASE</version>
1818
<relativePath/> <!-- lookup parent from repository -->
1919
</parent>
2020

jpa-element-collection-demo/src/main/java/com/example/jpa/model/User.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.example.jpa.model;
22

3-
import org.hibernate.validator.constraints.Email;
4-
53
import javax.persistence.*;
4+
import javax.validation.constraints.Email;
65
import javax.validation.constraints.NotNull;
76
import javax.validation.constraints.Size;
87
import java.util.HashSet;
@@ -15,7 +14,7 @@
1514
@Table(name = "users")
1615
public class User {
1716
@Id
18-
@GeneratedValue(strategy = GenerationType.AUTO)
17+
@GeneratedValue(strategy = GenerationType.IDENTITY)
1918
private Long id;
2019

2120
@NotNull

jpa-element-collection-demo/src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
22
spring.datasource.url=jdbc:mysql://localhost:3306/jpa_element_collection_demo?useSSL=false
33
spring.datasource.username=root
4-
spring.datasource.password=root
4+
spring.datasource.password=callicoder
55

66
# Hibernate
77

jpa-embeddable-demo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>org.springframework.boot</groupId>
1616
<artifactId>spring-boot-starter-parent</artifactId>
17-
<version>1.5.8.RELEASE</version>
17+
<version>2.0.0.RELEASE</version>
1818
<relativePath/> <!-- lookup parent from repository -->
1919
</parent>
2020

jpa-embeddable-demo/src/main/java/com/example/jpa/model/User.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@Table(name = "users")
1313
public class User {
1414
@Id
15-
@GeneratedValue(strategy = GenerationType.AUTO)
15+
@GeneratedValue(strategy = GenerationType.IDENTITY)
1616
private Long id;
1717

1818
@Embedded

0 commit comments

Comments
 (0)