package com.jasamedika.medifirst2000.entities;

import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;

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

@Entity
@Table(name = "SubUnitkerja_M", uniqueConstraints = {
		@UniqueConstraint(columnNames = { "objectUnitKerjaPegawaifk", "Name" }), })
@NoArgsConstructor
@Getter
@Setter
public class SubUnitKerjaPegawai extends BaseKeyValueMaster {

	public SubUnitKerjaPegawai(Integer id, String name) {
		super();
		this.id = id;
		this.setName(name);
	}

	public SubUnitKerjaPegawai(Integer id) {
		super();
		this.id = id;
	}

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

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "objectUnitKerjaPegawaifk")
	@Caption(value = "Object UnitKerjaPegawai ")
	private UnitKerjaPegawai unitKerja;

	@Column(name = "objectUnitKerjaPegawaifk", insertable = false, updatable = false)
	private Integer unitKerjaId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "objectJabatanKepalafk")
	@Caption(value = "Object Jabatan Kepala ")
	private Jabatan jabatanKepala;

	@Column(name = "objectJabatanKepalafk", insertable = false, updatable = false)
	private Integer jabatanKepalaId;
}
