package com.jasamedika.medifirst2000.entities;

import com.jasamedika.medifirst2000.base.BaseActive;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

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

/**
 * @author salmanoe
 * @since Dec 31, 2021
 */
@Getter
@Setter
@Entity
@Table(name = "sdm_mapjabatanprofesi_m")
public class MapJabatanProfesi extends BaseActive {

	private static final long serialVersionUID = 3888545942252692215L;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "jabatanfk")
	@NotNull(message = "Jabatan harus diisi")
	@Caption(value = "Jabatan")
	private Jabatan jabatan;

	@Column(name = "jabatanfk", insertable = false, updatable = false, nullable = false)
	private Integer jabatanId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "profesifk")
	@NotNull(message = "Profesi harus diisi")
	@Caption(value = "Profesi")
	private Profesi profesi;

	@Column(name = "profesifk", insertable = false, updatable = false, nullable = false)
	private Integer profesiId;

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

}
