feat: Event entity
This commit is contained in:
parent
1e1c726395
commit
736bc10463
2 changed files with 38 additions and 2 deletions
35
src/main/java/com/application/munera/data/Event.java
Normal file
35
src/main/java/com/application/munera/data/Event.java
Normal 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;
|
||||||
|
}
|
|
@ -39,11 +39,12 @@ public class Person {
|
||||||
@Column(name = "credit")
|
@Column(name = "credit")
|
||||||
private BigDecimal credit;
|
private BigDecimal credit;
|
||||||
|
|
||||||
// @JsonIgnore
|
|
||||||
@ManyToMany(mappedBy = "creditors")
|
@ManyToMany(mappedBy = "creditors")
|
||||||
private Set<Expense> creditorExpenses;
|
private Set<Expense> creditorExpenses;
|
||||||
|
|
||||||
// @JsonIgnore
|
|
||||||
@ManyToMany(mappedBy = "debtors")
|
@ManyToMany(mappedBy = "debtors")
|
||||||
private Set<Expense> debtorExpenses;
|
private Set<Expense> debtorExpenses;
|
||||||
|
|
||||||
|
@ManyToMany(mappedBy = "participants")
|
||||||
|
private Set<Event> participants;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue