package com.jasamedika.medifirst2000.entities;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.jasamedika.medifirst2000.base.BaseMaster;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

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

@Getter
@Setter
@Entity
@Table(name = "K3KelompokLpjGedung_M")
public class K3KelompokLpjGedung extends BaseMaster {

	@ManyToOne(fetch = LAZY)
	@Caption(value = "K3 Facillity Check")
	@JoinColumn(name = "ObjectK3FacillityCheckFK")
	private K3FacillityCheck k3FacillityCheck;

	@Column(name = "ObjectK3FacillityCheckFK", nullable = false, insertable = false, updatable = false)
	private Integer k3FacillityCheckId;

	@Caption(value = "Nama Kelompok")
	@Column(name = "NamaKelompok", length = 50, nullable = false)
	private String namaKelompok;

	@JsonBackReference
	@OneToMany(cascade = ALL, fetch = LAZY, mappedBy = "k3KelompokLpjGedung")
	private Set<K3ItemPeriksaGedung> k3ItemPeriksaGedung = new HashSet<>();

	@Id
	@GeneratedValue(strategy = SEQUENCE, generator = "public.k3kelompoklpjgedung_m_id_seq")
	@SequenceGenerator(name = "public.k3kelompoklpjgedung_m_id_seq", sequenceName = "public.k3kelompoklpjgedung_m_id_seq", allocationSize = 1)
	@Column(name = "id")
	protected Integer id;

}