128 lines
2.9 KiB
Java
128 lines
2.9 KiB
Java
package com.mycompany.myapp.domain;
|
|
|
|
import org.hibernate.annotations.Cache;
|
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
|
|
|
import javax.persistence.*;
|
|
import javax.validation.constraints.*;
|
|
import java.io.Serializable;
|
|
import java.math.BigDecimal;
|
|
import java.time.ZonedDateTime;
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
import java.util.Objects;
|
|
|
|
/**
|
|
* A Operation.
|
|
*/
|
|
@Entity
|
|
@Table(name = "operation")
|
|
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
|
|
public class Operation implements Serializable {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
|
private Long id;
|
|
|
|
@NotNull
|
|
@Column(name = "date", nullable = false)
|
|
private ZonedDateTime date;
|
|
|
|
@Column(name = "description")
|
|
private String description;
|
|
|
|
@NotNull
|
|
@Column(name = "amount", precision=10, scale=2, nullable = false)
|
|
private BigDecimal amount;
|
|
|
|
@ManyToOne
|
|
private BankAccount bankAccount;
|
|
|
|
@ManyToMany
|
|
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
|
|
@JoinTable(name = "operation_label",
|
|
joinColumns = @JoinColumn(name="operations_id", referencedColumnName="ID"),
|
|
inverseJoinColumns = @JoinColumn(name="labels_id", referencedColumnName="ID"))
|
|
private Set<Label> labels = new HashSet<>();
|
|
|
|
public Long getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(Long id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public ZonedDateTime getDate() {
|
|
return date;
|
|
}
|
|
|
|
public void setDate(ZonedDateTime date) {
|
|
this.date = date;
|
|
}
|
|
|
|
public String getDescription() {
|
|
return description;
|
|
}
|
|
|
|
public void setDescription(String description) {
|
|
this.description = description;
|
|
}
|
|
|
|
public BigDecimal getAmount() {
|
|
return amount;
|
|
}
|
|
|
|
public void setAmount(BigDecimal amount) {
|
|
this.amount = amount;
|
|
}
|
|
|
|
public BankAccount getBankAccount() {
|
|
return bankAccount;
|
|
}
|
|
|
|
public void setBankAccount(BankAccount bankAccount) {
|
|
this.bankAccount = bankAccount;
|
|
}
|
|
|
|
public Set<Label> getLabels() {
|
|
return labels;
|
|
}
|
|
|
|
public void setLabels(Set<Label> labels) {
|
|
this.labels = labels;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (this == o) {
|
|
return true;
|
|
}
|
|
if (o == null || getClass() != o.getClass()) {
|
|
return false;
|
|
}
|
|
Operation operation = (Operation) o;
|
|
if(operation.id == null || id == null) {
|
|
return false;
|
|
}
|
|
return Objects.equals(id, operation.id);
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return Objects.hashCode(id);
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "Operation{" +
|
|
"id=" + id +
|
|
", date='" + date + "'" +
|
|
", description='" + description + "'" +
|
|
", amount='" + amount + "'" +
|
|
'}';
|
|
}
|
|
}
|