generated key...

时间:2023-11-10 22:53:32

1. javax.persistence.GeneratedValue

@Data

@MappedSuperclass

public abstract class UUIDEntity {

@Id

@GeneratedValue(generator = "systemUUID")

@Column(name = "id", length = Constants.UUID_LENGTH)

private String id;

}

2. hibernate generatedValue

@ToString(callSuper = true)

@EqualsAndHashCode(callSuper = true)

@Entity @Data @Table(name = "T_TEST")

@GenericGenerator(name="systemUUID",strategy="uuid2")

public class TestEntity extends UUIDEntity {