我有一个@ManyToMany关系注释,它会生成一个带有唯一约束的不需要的索引。我不知道如何防止这种情况。这是我的注释的样子:
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "ab_join_table",
joinColumns = @JoinColumn(name = "entity_a_uid", referencedColumnName = "uid", insertable = false, updatable = false, unique = false),
inverseJoinColumns = @JoinColumn(name ="entity_b_uid", referencedColumnName = "uid", insertable = false, updatable = false, unique = false),
foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
@org.hibernate.annotations.ForeignKey(name = "none", inverseName = "none")
private Set<EntityB> entities = new HashSet<>();
基本上,我有一个表EntityA和EntityB,它们具有多对多关系,并使用连接表来桥接关系。没什么特别的。问题是,UID不希望是唯一的,我不希望添加这个唯一约束!它被添加为索引
"uk_5u10jim5rbm0dggygeebnr6ve" UNIQUE CONSTRAINT, btree (uid)
如何防止这种情况?
我的专栏(索引是以不合需要的方式创建的)注释如下:
@Column(name="uid", nullable = false, unique = false)
private String uid;