fix: re-do in the event entity

still tentative
This commit is contained in:
filippo-ferrari 2024-06-12 22:03:52 +02:00
parent 18680a0f90
commit fee0309c4a
3 changed files with 5 additions and 14 deletions

View file

@ -5,17 +5,14 @@ import jakarta.validation.constraints.Size;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.Set;
@Entity @Entity
@Setter
@Getter @Getter
@Setter
@Table(name = "events") @Table(name = "events")
public class Event { public class Event {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "Id", unique = true, nullable = false)
private Long id; private Long id;
@Size(max = 100) @Size(max = 100)
@ -25,11 +22,4 @@ public class Event {
@Size(max = 100) @Size(max = 100)
@Column(name = "Description") @Column(name = "Description")
private String description; private String description;
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(
name = "Event_participants",
joinColumns = @JoinColumn(name = "event_id"),
inverseJoinColumns = @JoinColumn(name = "participant_id"))
private Set<Person> participants;
} }

View file

@ -57,6 +57,10 @@ public class Expense {
inverseJoinColumns = @JoinColumn(name = "people_id")) inverseJoinColumns = @JoinColumn(name = "people_id"))
private Set<Person> debtors; private Set<Person> debtors;
@ManyToOne
@JoinColumn(name = "EventId")
private Event event;
@Column(name = "Date", nullable = false, columnDefinition = "DATE DEFAULT CURRENT_DATE") @Column(name = "Date", nullable = false, columnDefinition = "DATE DEFAULT CURRENT_DATE")
private LocalDate date; private LocalDate date;
} }

View file

@ -44,7 +44,4 @@ public class Person {
@ManyToMany(mappedBy = "debtors") @ManyToMany(mappedBy = "debtors")
private Set<Expense> debtorExpenses; private Set<Expense> debtorExpenses;
@ManyToMany(mappedBy = "participants")
private Set<Event> participants;
} }