package com.jasamedika.medifirst2000.entities;

import com.fasterxml.jackson.annotation.JsonBackReference;
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.Date;
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 = "K3CheckListFacillitySefety_T")
public class K3CheckListFacillitySefety extends BaseTransaction {

	@NotNull(message = "Tanggal tidak boleh Kosong")
	@Caption(value = "Tanggal")
	@Column(name = "Tanggal", nullable = false)
	private Date tanggal;

	@ManyToOne(fetch = LAZY)
	@Caption(value = "Ruangan")
	@JoinColumn(name = "ObjectRuanganFK")
	private Ruangan ruangan;

	@Column(name = "ObjectRuanganFK", nullable = false, insertable = false, updatable = false)
	private Integer ruanganId;

	@JsonBackReference
	@OneToMany(cascade = ALL, fetch = LAZY, mappedBy = "k3CheckListFacillitySefety")
	private Set<K3CheckListFacillitySefetyDetail> k3CheckListFacillitySefetyDetail = new HashSet<>();

}
