package com.bytesw.bytebot.etl.model;

import com.bytesw.bytebot.model.Channel;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

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

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

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

    @Column(name = "session_date", nullable = false)
    private OffsetDateTime sessionDate;

    @Column(name = "session_ledat", nullable = false)
    private OffsetDateTime lastEventDate;

    @Column(name = "session_frdat", nullable = false)
    private OffsetDateTime responseDate;

    @ManyToOne
    @JoinColumn(name = "chan_id", referencedColumnName = "chan_id")
    private Channel channel;

    @ManyToOne(optional = false)
    @JoinColumn(name = "user_id", referencedColumnName = "user_id")
    private User user;
}
