package de.thpeetz.kontor.bookshelf.data;

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

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

@Getter
@Setter
@ToString
@Entity
@Table(indexes = @Index(columnList = "title"), uniqueConstraints = @UniqueConstraint(columnNames = {"title"}))
public class Article extends AbstractEntity {

    @NotEmpty
    private String title;

    @OneToMany(fetch = FetchType.EAGER, mappedBy = "article")
    @Nullable
    private List<ArticleAuthor> authors = new LinkedList<>();
}
