springBoot JPA uuid生成策略
//插件安装 //IDEA插件安装地址:https://jingyan.baidu.com/article/0a52e3f4e53ca1bf63ed725c.html //自动生成get和set toString() <!--lombok 注解--> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.10</version> </dependency>
uuid自动生成策略
package com.zgh.scada.zghsc.entity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.zgh.scada.zghsc.framework.extend.entity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
/**
* Test
*/
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
@Entity
@Table(name = "test")
@GenericGenerator(name = "jpa-uuid", strategy = "uuid")
@Setter
@Getter
@ToString
public class Test{
@Id
@GeneratedValue(generator = "jpa-uuid")
@Column(length = 32)
private String id;
/**
* 协议连接id
*/
@Column(name="treaty_con_id",columnDefinition = "int(11) default null comment 协议连接id")
private Integer treatyConId;
}
