Skip to content

Commit e3e9294

Browse files
committed
update spring-boot-jpa-hikari
1 parent 7d2f0fd commit e3e9294

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

spring-boot-jpa-hikari/src/main/java/com/springboot/springbootjpahikari/model/UserModel.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.springboot.springbootjpahikari.model;
22

33
import lombok.Data;
4+
import org.hibernate.annotations.GenericGenerator;
45

56
import javax.persistence.*;
67

@@ -14,7 +15,9 @@
1415
@Table(name = "user")
1516
public class UserModel {
1617
@Id
17-
@GeneratedValue
18+
@GeneratedValue(generator = "paymentableGenerator")
19+
@GenericGenerator(name = "paymentableGenerator", strategy = "uuid")
20+
@Column(name ="ID", nullable=false, length=36)
1821
private Long id;
1922
@Column(nullable = true, unique = true)
2023
private String nickName;

spring-boot-jpa-hikari/src/main/java/com/springboot/springbootjpahikari/repository/UserRepository.java

+9
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,19 @@
33
import com.springboot.springbootjpahikari.model.UserModel;
44
import org.springframework.data.jpa.repository.JpaRepository;
55

6+
import java.util.List;
7+
68
/**
79
* @Date: 2019/9/17 16:51
810
* @Version: 1.0
911
* @Desc:
1012
*/
1113
public interface UserRepository extends JpaRepository<UserModel, Long> {
14+
UserModel getByIdIs(Long id);
15+
16+
UserModel findByNickName(String nickName);
17+
18+
int countByAge(int age);
19+
20+
List<UserModel> findByNickNameLike(String nickName);
1221
}

spring-boot-jpa-hikari/src/main/resources/application.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ spring:
44
application:
55
name: spring-boot-jpa-hikari
66
jpa:
7+
database: mysql
8+
show-sql: true
9+
generate-ddl: true
10+
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
711
hibernate:
812
ddl-auto: update
9-
database: mysql
1013
datasource:
11-
url: jdbc:mysql://172.16.96.112:3306/test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false
14+
url: jdbc:mysql://192.168.0.128:3306/test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false
1215
username: root
1316
password: 123456
1417
driver-class-name: com.mysql.cj.jdbc.Driver
@@ -20,4 +23,4 @@ spring:
2023
connection-timeout: 30000
2124
max-lifetime: 1800000
2225
pool-name: DatebookHikariCP
23-
maximum-pool-size: 10
26+
maximum-pool-size: 5

0 commit comments

Comments
 (0)