package com.jasamedika.medifirst2000.entities;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.jasamedika.medifirst2000.base.BaseTransaction;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.HashSet;
import java.util.Set;

import static javax.persistence.CascadeType.ALL;
import static javax.persistence.FetchType.LAZY;

@Getter
@Setter
@Entity
@Table(name = "GeneralCheckUp_T")
public class GeneralCheckUp extends BaseTransaction {

	@ManyToOne
	@JoinColumn(name = "ObjectPegawaiFk")
	@NotNull(message = "Pegawai tidak boleh kosong")
	@Caption(value = "Pegawai")
	private Pegawai pegawai;

	@Column(name = "ObjectPegawaiFk", insertable = false, updatable = false, nullable = false)
	private Integer pegawaiId;

	@JsonManagedReference
	@OneToMany(cascade = ALL, fetch = LAZY, mappedBy = "generalCheckUp")
	@Caption(value = "dataGeneralCheckUpSet")
	private Set<DataGeneralCheckUp> dataGeneralCheckUpSet = new HashSet<>();

}
