JPA设置主键索引注解

import lombok.Data; //这个注解是下载了lombok插件,简化get/set方法 import javax.persistence.*; /** * Created by Hman on 2017/6/17. */ @Data @Entity @Table(name = "TB_STUDENT",indexes = {@Index(name = "TSGS_CODE",columnList = "code")})//索引name值不能相同,否则无法创建索引 public class GoodsStockDo {@Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String code; private String name; private Integer age; }

    推荐阅读