package com.jasamedika.medifirst2000.entities;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
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 = "JenisOrder_M")
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class JenisOrder extends BaseMaster {

	@NotNull(message = "Jenis Order tidak boleh kosong")
	@Column(name = "JenisOrder", nullable = false, length = 50)
	@Caption(value = "Jenis Order")
	private String jenisOrder;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectDepartemenFk")
	@NotNull(message = "Kd Departemen tidak boleh kosong")
	@Caption(value = "Object Departemen")
	private Departemen departemen;

	@Column(name = "ObjectDepartemenFk", insertable = false, updatable = false)
	private Integer departemenId;

	@NotNull(message = "Kd Jenis Order tidak boleh kosong")
	@Column(name = "KdJenisOrder", nullable = false)
	@Caption(value = "Kode Jenis Order")
	private Byte kdJenisOrder;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectJenisOrderHeadFk")
	@Caption(value = "Object Jenis Order Head")
	private JenisOrder jenisOrderHead;

	@Column(name = "ObjectJenisOrderHeadFk", insertable = false, updatable = false, nullable = false)
	private Integer jenisOrderHeadId;

	@NotNull(message = "QJenis Order tidak boleh kosong")
	@Column(name = "QJenisOrder", nullable = false)
	@Caption(value = "QJenis Order")
	private Byte qJenisOrder;

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

}