package com.bytesw.bytebot.etl.model;

import com.bytesw.bytebot.etl.converter.MessageTypeConverter;
import com.bytesw.bytebot.etl.enums.MessageTypeEnum;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.OffsetDateTime;

@Cacheable(false)
@Entity
@Getter @Setter @ToString @Builder
@Table(name="avb_message")
@NamedQuery(name = "Message.findByPK", query = "Select p from Message p where p.id = ?1")
public class Message {

    @Id
    @Column(name = "messa_id")
    @SequenceGenerator(name = "AVB_MESSAGE_GENERATOR", sequenceName = "AVB_MESSAGE_SEQ", initialValue = 1, allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "AVB_MESSAGE_GENERATOR")
    private Long id;

    @Column(name = "session_id")
    private Long sessionId;

    @Column(name = "messa_date")
    private OffsetDateTime date;

    @Column(name = "messa_cont")
    private String content;

    @Column(name = "messa_corre")
    private int correlative;

    @Column(name = "messa_prob")
    private BigDecimal probability;

    @Convert(converter =  MessageTypeConverter.class)
    @Column(name = "messa_type")
    private MessageTypeEnum type;

    @Column(name = "inten_id")
    private Long intentId;
}
