@Entity @Table(name ="user", uniqueConstraints={@UniqueConstraint(columnNames={"loginName"})}, //唯一约束 indexes = {@Index(columnList = "roleId")}) //为字段roleId加上索引 public class User implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) //主键由数据库自动生成(主要是自动增长型) private long id; @Column(nullable=false,length=255) String loginName; @Column(nullable=false) String password; @Column(nullable=true,length=255) String name; @Column int status; @Column(nullable=true) String phone; @Column(nullable=true) Date lastTime; @Column(nullable=true) Date ctime; @Column(nullable=true) String descripe; @Column(nullable=true) int isDelete; @Column() int roleId;
spring-data-jpa为实体类属性添加索引
最新推荐文章于 2023-06-11 12:05:27 发布