JPA table注解

@Entity
@Table(name = "literature",
        uniqueConstraints = {@UniqueConstraint(columnNames = {"doc_href", "doc_title"})})
public class Literature extends AbstractDBModel {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "doc_href")
    private String docHref;
 
    @Column(name = "doc_title")
    private String docTitle;
}

mysql已经配置默认引擎是innodb,而springboot中spring-data-jpa自动生成的数据库默认是myisam引擎的,myisam引擎创建Unique最大不能超过1000字符,所以,要把数据库引擎改为innodb,只需要在application.yml配置文件中加入:

spring.jpa.database-platform: org.hibernate.dialect.MySQL5InnoDBDialect

你可能感兴趣的:(JPA table注解)