我有一个spring boot应用程序并使用以下User模型类。
@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启动应用程序后,它会自动为sdmForCircle,userWorkingForOperator和techLeadForNode创建表,但这些表是使用不必要的唯一约束创建的。我想停止自动添加ADDED的唯一约束。
请建议。
答案 0 :(得分:0)
如果您不想要唯一性,请改用ManyToMany。
答案 1 :(得分:0)
Another approach might be turning off automatic ddl generation. You can do it by adding Spring Boot properties:
spring.jpa.generate-ddl=false
spring.jpa.hibernate.ddl-auto=none