File tree 3 files changed +19
-4
lines changed
spring-boot-jpa-hikari/src/main
java/com/springboot/springbootjpahikari
3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 1
1
package com .springboot .springbootjpahikari .model ;
2
2
3
3
import lombok .Data ;
4
+ import org .hibernate .annotations .GenericGenerator ;
4
5
5
6
import javax .persistence .*;
6
7
14
15
@ Table (name = "user" )
15
16
public class UserModel {
16
17
@ Id
17
- @ GeneratedValue
18
+ @ GeneratedValue (generator = "paymentableGenerator" )
19
+ @ GenericGenerator (name = "paymentableGenerator" , strategy = "uuid" )
20
+ @ Column (name ="ID" , nullable =false , length =36 )
18
21
private Long id ;
19
22
@ Column (nullable = true , unique = true )
20
23
private String nickName ;
Original file line number Diff line number Diff line change 3
3
import com .springboot .springbootjpahikari .model .UserModel ;
4
4
import org .springframework .data .jpa .repository .JpaRepository ;
5
5
6
+ import java .util .List ;
7
+
6
8
/**
7
9
* @Date: 2019/9/17 16:51
8
10
* @Version: 1.0
9
11
* @Desc:
10
12
*/
11
13
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 );
12
21
}
Original file line number Diff line number Diff line change @@ -4,11 +4,14 @@ spring:
4
4
application :
5
5
name : spring-boot-jpa-hikari
6
6
jpa :
7
+ database : mysql
8
+ show-sql : true
9
+ generate-ddl : true
10
+ database-platform : org.hibernate.dialect.MySQL5InnoDBDialect
7
11
hibernate :
8
12
ddl-auto : update
9
- database : mysql
10
13
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
12
15
username : root
13
16
password : 123456
14
17
driver-class-name : com.mysql.cj.jdbc.Driver
@@ -20,4 +23,4 @@ spring:
20
23
connection-timeout : 30000
21
24
max-lifetime : 1800000
22
25
pool-name : DatebookHikariCP
23
- maximum-pool-size : 10
26
+ maximum-pool-size : 5
You can’t perform that action at this time.
0 commit comments