休眠自定义主键索引名称

时间:2018-12-11 13:42:46

标签: hibernate jpa spring-data-jpa

我可以在Hibernate上编写自定义主键索引名称吗?

例如, 我有这样的实体:

@Entity
public class Person{

    @Id
    @GeneratedValue(generator = "SWIFT_JOPT_SEQ", strategy = GenerationType.SEQUENCE)
    @SequenceGenerator(name = "SWIFT_JOPT_SEQ", allocationSize = 1, sequenceName = "SWIFT_JOPT_SEQ", schema = "swift")
    @Column(name = "id")
    private long id;

}

Hibernate生成索引名称{table_name} _pkey

当我这样声明索引

@Table(name = "person", schema = "swift", indexes = {
    @Index(columnList = "id", name = "idx_p_id", unique = true) })

休眠不会覆盖主键索引名称并创建新索引。

0 个答案:

没有答案