diff --git a/src/main/java/com/application/munera/data/Event.java b/src/main/java/com/application/munera/data/Event.java new file mode 100644 index 0000000..e6bfc23 --- /dev/null +++ b/src/main/java/com/application/munera/data/Event.java @@ -0,0 +1,35 @@ +package com.application.munera.data; + +import jakarta.persistence.*; +import jakarta.validation.constraints.Size; +import lombok.Getter; +import lombok.Setter; + +import java.util.Set; + +@Entity +@Setter +@Getter +@Table(name = "events") +public class Event { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "Id", unique = true, nullable = false) + private Long id; + + @Size(max = 100) + @Column(name = "Name", nullable = false) + private String name; + + @Size(max = 100) + @Column(name = "Description") + private String description; + + @ManyToMany(fetch = FetchType.EAGER) + @JoinTable( + name = "Event_participants", + joinColumns = @JoinColumn(name = "event_id"), + inverseJoinColumns = @JoinColumn(name = "participant_id")) + private Set participants; +} diff --git a/src/main/java/com/application/munera/data/Person.java b/src/main/java/com/application/munera/data/Person.java index 1681c06..cf70fd5 100644 --- a/src/main/java/com/application/munera/data/Person.java +++ b/src/main/java/com/application/munera/data/Person.java @@ -39,11 +39,12 @@ public class Person { @Column(name = "credit") private BigDecimal credit; -// @JsonIgnore @ManyToMany(mappedBy = "creditors") private Set creditorExpenses; -// @JsonIgnore @ManyToMany(mappedBy = "debtors") private Set debtorExpenses; + + @ManyToMany(mappedBy = "participants") + private Set participants; }