вроде связи добавлены

This commit is contained in:
VictoriaPresnyakova 2023-04-09 19:53:42 +04:00
parent 943027b803
commit 0a0ee7145b
3 changed files with 20 additions and 2 deletions

View File

@ -18,6 +18,9 @@ public class Component {
@Column(name = "amount")
private Integer amount;
@ManyToMany(mappedBy = "componentsList")
private List<Favor> favorsList;
public Component() {
}

View File

@ -18,6 +18,15 @@ public class Favor {
@Column(name = "price")
private Integer price;
@ManyToMany(mappedBy = "favorsList")
private List<Order> ordersList;
@ManyToMany
@JoinTable(name = "favor_component",
joinColumns = @JoinColumn(name = "favor_fk"),
inverseJoinColumns = @JoinColumn(name = "component_fk"))
private List<Component> componentsList;
public Favor() {
}
@ -46,7 +55,7 @@ public class Favor {
public void setPrice(Integer price) {
this.price = price;
}
@Override
public boolean equals(Object o) {

View File

@ -16,6 +16,13 @@ public class Order {
private Long id;
@Column(name = "date")
private Date date;
@ManyToMany
@JoinTable(name = "order_favor",
joinColumns = @JoinColumn(name = "order_fk"),
inverseJoinColumns = @JoinColumn(name = "favor_fk"))
private List<Favor> favorsList;
public Order(){
}
@ -38,7 +45,6 @@ public class Order {
public void setDate(Date date) {
this.date = date;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;