package io.gmss.fiscad.entities.infocad.parametre;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.infocad.metier.Parcelle;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import java.io.Serializable;
import java.util.List;
import java.util.Set;

@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@SQLDelete(sql =
        "UPDATE nature_domaine " +
                "SET deleted = true " +
                "WHERE id = ?")
@Where(clause = " deleted = false")
public class NatureDomaine extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String libelle;
    //@JsonIgnore
    @ManyToOne
    private TypeDomaine typeDomaine;
//    @JsonIgnore
//    @OneToMany(mappedBy = "natureDomaine")
//    private List<Parcelle> parcelles;

    @ManyToMany
    @JoinTable(name = "natureDomaine_typePersonne",
            joinColumns = @JoinColumn(name = "nature_domaine_id"),
            inverseJoinColumns = @JoinColumn(name = "type_personne_id")
    )
    private Set<TypePersonne> typePersonnes;


}
