package com.iqser.red.service.persistence.management.v1.processor.entity.dossier;

import java.util.ArrayList;
import java.util.List;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "dossier_status")
public class DossierStatusEntity {

    @Id
    private String id;

    @Column
    private String name;

    @Column
    private String description;

    @Column
    private String color;

    @Column
    private int rank;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "dossier_template_id")
    private DossierTemplateEntity dossierTemplate;

    @Column(updatable = false, insertable = false, name = "dossier_template_id")
    private String dossierTemplateId;

    @OneToMany(mappedBy = "dossierStatus", fetch = FetchType.LAZY)
    @Fetch(FetchMode.SUBSELECT)
    private List<DossierEntity> dossiers = new ArrayList<>();

}
