feat: Event entity

This commit is contained in:
filippo-ferrari 2024-06-11 21:28:48 +02:00
parent 1e1c726395
commit 736bc10463
2 changed files with 38 additions and 2 deletions

View file

@ -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<Person> participants;
}

View file

@ -39,11 +39,12 @@ public class Person {
@Column(name = "credit")
private BigDecimal credit;
// @JsonIgnore
@ManyToMany(mappedBy = "creditors")
private Set<Expense> creditorExpenses;
// @JsonIgnore
@ManyToMany(mappedBy = "debtors")
private Set<Expense> debtorExpenses;
@ManyToMany(mappedBy = "participants")
private Set<Event> participants;
}