package io.delphiplatform.api.v3.rdb.entity;

import java.io.Serializable;
import java.util.Objects;

import javax.persistence.Embeddable;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import lombok.Getter;
import lombok.Setter;

@Embeddable
@Getter
@Setter
public class ParticipantId implements Serializable {

    private static final long serialVersionUID = 1975632327438947965L;
    private String participantId;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "artist_id", nullable = false)
    private ArtistEntity artist;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ParticipantId that = (ParticipantId) o;
        return Objects.equals(participantId, that.participantId) &&
            Objects.equals(artist, that.artist);
    }

    @Override
    public int hashCode() {
        return Objects.hash(participantId, artist);
    }
}
