JPA创建实体类映射表+ 创建索引

 

创建表 tb_student + 创建索引

主键:studentId

索引:

  • 联合索引: index_tb_student
  • 单个索引: index_student_studentName
  • 单个索引: index_student_studentAge
import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
  
import lombok.Data;
  
@Data
@Entity
@Table(name = "tb_student",
       indexes = { @Index(name = "index_tb_student", columnList = "classNo,studentName"),
                   @Index(name = "index_student_studentName", columnList = "studentName"),
                   @Index(name = "index_student_studentAge", columnList = "studentAge") })
public class Student {
  
    @Id
    private String studentId;
  
    @Column
    private String studentName;
  
    @Column
    private Integer studentAge;
  
    @Column
    private String classNo;
    
    @Column(precision = 18, scale = 4)
	private BigDecimal height;
    
    @Column
	private Date lastModiftyDate;
  
}

  

  

  

posted on 2022-01-13 18:11  dreamstar  阅读(435)  评论(0编辑  收藏  举报