我想添加 index(@Index) 但我不能。当我在另一个属性(displayName)上添加@Index 时,它可以工作并在数据库上创建这个索引,但是当我将它添加到“联系人”属性时它不起作用。
@Entity
@Table(name = "TBL_PARTY")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "PARTY_TYPE",
discriminatorType = DiscriminatorType.STRING)
@SequenceGenerator(name = "idGenerator", sequenceName = "SEQ_PARTY",
allocationSize = 1)
public abstract class Party extends BaseEntity {
.....
@OneToMany(fetch = FetchType.LAZY)
@JoinColumn(name = "PARTY_ID", nullable = false,unique = true)
@Cascade(value = {CascadeType.SAVE_UPDATE, CascadeType.DELETE})
**@Index(name = "IDX_CONTACTS")**
public List<Contact> getContacts() {
return contacts;
}
**@Index(name="IDX_NAME)**
@Column(name = "DISPLAY_NAME")
public String getDisplayName() {
return displayName;
}
你有什么建议吗?