package org.ros.chatto.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import java.time.Instant;

import lombok.Data;

@Data
@Entity
@Table(name = "chat_messages")
public class ChatMessage {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "m_id")
	private Long messageID;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "from_user")
	private ChatUser fromUser;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "to_user")
	private ChatUser toUser;
	
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "message")
	private MessageCipher messageCipher;
	
	private Instant messageTime; 
}
