当前位置:Gxlcms > mysql > Mysql生成UUID的操作_MySQL

Mysql生成UUID的操作_MySQL

时间:2021-07-01 10:21:17 帮助过:13人阅读

bitsCN.com


Mysql生成UUID的操作

Hibernate中这样配置主键生成后,mysql中并未指定主键生成机制,

使用Navicat通过sql语句insert数据时仍需指定Id,

Java代码

INSERT INTO g_distinct VALUES ( replace(uuid(),'-',''),'110101','东城区','110100');

Java代码

@Id

@GenericGenerator(name = "generator", strategy = "uuid.hex")

@GeneratedValue(generator = "generator")

@Column(name = "LOCATION_ID", length = 40)

public String getLocationId() {

return locationId;

}

bitsCN.com

人气教程排行