forked from mtusi2026/mtusi2026lab4
44 lines
1.0 KiB
Java
44 lines
1.0 KiB
Java
package org.example.model;
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
import jakarta.persistence.*;
|
|
import lombok.*;
|
|
import org.hibernate.annotations.CreationTimestamp;
|
|
|
|
import java.time.Instant;
|
|
import java.time.LocalDateTime;
|
|
import java.util.UUID;
|
|
|
|
@Entity
|
|
@Table(name = "messages")
|
|
@Getter
|
|
@Setter
|
|
@NoArgsConstructor
|
|
@AllArgsConstructor
|
|
@Builder
|
|
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
|
|
public class Message {
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.UUID)
|
|
private UUID id;
|
|
|
|
@Column(name = "chat_id", nullable = false)
|
|
@JsonProperty("chat_id")
|
|
private UUID chatId;
|
|
|
|
@Column(name = "sender_id", nullable = false)
|
|
@JsonProperty("sender_id")
|
|
private UUID senderId;
|
|
|
|
@Column(nullable = false, columnDefinition = "TEXT")
|
|
private String text;
|
|
|
|
@CreationTimestamp
|
|
@Column(name = "created_at", nullable = false, updatable = false)
|
|
@JsonProperty("created_at")
|
|
private Instant createdAt;
|
|
|
|
}
|