hibernate在关系表上创建另一个不必要的索引

时间:2017-09-24 20:36:59

标签: java hibernate

我有这样的关系:一个房间有很多用户,一个用户属于很多房间。我真的不需要用户之间的连接 - >房间,所以我删除并休眠创建了一个名为room_users的关系表,这很好 而且,创建了这两个索引:

enter image description here

您可以想象,uk_rdxxx索引是错误的,并且不允许我为每个房间保存多个用户。而且我不知道它来自哪里。这是我的班级:

@Entity
@Table(name = "rooms", indexes = {
    @Index(columnList = "uid", unique = true),
    @Index(columnList = "fullName", name = "full_name_idx")
})
@JsonInclude(content = Include.NON_NULL)
@Data
@EqualsAndHashCode(callSuper = true, of = {"uid"})
@ToString(of = {"name", "uid", "fullName"})
@NamedEntityGraphs(
    @NamedEntityGraph(name = "with-messages",
        attributeNodes = {@NamedAttributeNode("messages")}))
public class Room extends AbstractAggregateRoot implements Serializable {

  @OneToMany(targetEntity = User.class, cascade = {})
  @JsonIgnore
  private Set<User> users = new HashSet<>();

0 个答案:

没有答案
相关问题