package de.thpeetz.kontor.media.data;

import de.thpeetz.kontor.common.data.AbstractEntity;
import jakarta.annotation.Nullable;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotEmpty;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.util.LinkedList;
import java.util.List;

@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
@Slf4j
@Entity
public class MediaActor extends AbstractEntity {

    @NotEmpty
    private String name;

    @Nullable
    @Column(unique = true)
    private String url;

    @OneToMany(fetch = FetchType.EAGER, mappedBy = "media_actor", cascade = CascadeType.REFRESH, orphanRemoval = true)
    @Nullable
    List<MediaActorFile> mediaActorFiles = new LinkedList<>();
}
