69 lines
2.2 KiB
Java
69 lines
2.2 KiB
Java
package ru.akarpov.is1.entity;
|
|
|
|
import jakarta.persistence.*;
|
|
import jakarta.validation.constraints.NotNull;
|
|
import java.util.Date;
|
|
|
|
@Entity
|
|
@Table(name = "import_operation")
|
|
@NamedQueries({
|
|
@NamedQuery(name = "ImportOperation.findByUser",
|
|
query = "SELECT io FROM ImportOperation io WHERE io.userId = :userId ORDER BY io.createdAt DESC"),
|
|
@NamedQuery(name = "ImportOperation.findAll",
|
|
query = "SELECT io FROM ImportOperation io ORDER BY io.createdAt DESC")
|
|
})
|
|
public class ImportOperation {
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "import_operation_seq_gen")
|
|
@SequenceGenerator(name = "import_operation_seq_gen", sequenceName = "import_operation_seq", allocationSize = 1)
|
|
private Long id;
|
|
|
|
@NotNull
|
|
@Column(name = "user_id", nullable = false)
|
|
private Long userId;
|
|
|
|
@NotNull
|
|
@Enumerated(EnumType.STRING)
|
|
@Column(name = "status", nullable = false)
|
|
private ImportStatus status;
|
|
|
|
@Column(name = "objects_count")
|
|
private Integer objectsCount;
|
|
|
|
@Column(name = "error_message", columnDefinition = "TEXT")
|
|
private String errorMessage;
|
|
|
|
@NotNull
|
|
@Temporal(TemporalType.TIMESTAMP)
|
|
@Column(name = "created_at", nullable = false, updatable = false)
|
|
private Date createdAt;
|
|
|
|
public ImportOperation() {
|
|
this.createdAt = new Date();
|
|
}
|
|
|
|
@PrePersist
|
|
protected void onCreate() {
|
|
if (createdAt == null) {
|
|
createdAt = new Date();
|
|
}
|
|
}
|
|
|
|
public Long getId() { return id; }
|
|
public void setId(Long id) { this.id = id; }
|
|
|
|
public Long getUserId() { return userId; }
|
|
public void setUserId(Long userId) { this.userId = userId; }
|
|
|
|
public ImportStatus getStatus() { return status; }
|
|
public void setStatus(ImportStatus status) { this.status = status; }
|
|
|
|
public Integer getObjectsCount() { return objectsCount; }
|
|
public void setObjectsCount(Integer objectsCount) { this.objectsCount = objectsCount; }
|
|
|
|
public String getErrorMessage() { return errorMessage; }
|
|
public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; }
|
|
|
|
public Date getCreatedAt() { return createdAt; }
|
|
public void setCreatedAt(Date createdAt) { this.createdAt = createdAt; }
|
|
} |