package com.jasamedika.medifirst2000.entities;

import com.jasamedika.medifirst2000.base.BaseMaster;
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;

@Getter
@Setter
@Entity
@Table(name = "Kelas_M")
public class Kelas extends BaseMaster {

	@NotNull(message = "Nama Kelas tidak boleh kosong")
	@Column(name = "NamaKelas", nullable = false, length = 30)
	@Caption(value = "Nama Kelas")
	private String namaKelas;

	@NotNull(message = "No Urut tidak boleh kosong")
	@Column(name = "NoUrut", nullable = false)
	@Caption(value = "No Urut")
	private Byte noUrut;

	@NotNull(message = "QKelas tidak boleh kosong")
	@Column(name = "QKelas", nullable = false)
	@Caption(value = "QKelas")
	private Byte qKelas;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectKelasHeadFk")
	private Kelas kelasHead;

	@Column(name = "ObjectKelasHeadFk", insertable = false, updatable = false)
	private Integer kelasHeadId;

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

}