gpt4 book ai didi

mysql - spring data 创建了不必要的唯一约束

转载 作者:行者123 更新时间:2023-11-29 21:01:57 25 4
gpt4 key购买 nike

我有一个 Spring Boot 应用程序并使用以下用户模型类。

 @Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

private String name;
private String emailAddress;
private Boolean active;
private String password;
private boolean techLead;
private boolean sdm;
private boolean admin;

@OneToMany(fetch = FetchType.EAGER)
private Set<Circle> sdmForCircle;

@OneToMany(fetch = FetchType.EAGER)
private Set<Node> techLeadForNode;

@OneToMany(fetch = FetchType.EAGER)
private Set<Operator> userWorkingForOperator;

..................

一旦我加载 Spring boot 应用程序,它就会自动为 sdmForCircle 、userWorkingForOperator 和 techLeadForNode 创建表,但创建这些表时带有不必要的唯一约束。我想停止自动添加唯一约束。

请提出建议。

最佳答案

如果您不想要唯一性,请改用ManyToMany。

关于mysql - spring data 创建了不必要的唯一约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37145650/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com