package com.jasamedika.medifirst2000.entities;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jasamedika.medifirst2000.base.BaseTransaction;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;

import static javax.persistence.FetchType.LAZY;

@Getter
@Setter
@Entity
@Table(name = "IpsrsMesinGenset_T")
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class IpsrsMesinGenset extends BaseTransaction {

	@OneToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectIpsrsPemakaianMesinFk")
	@Caption(value = "Ipsrs Pemakaian Mesin")
	private IpsrsPemakaianMesin ipsrsPemakaianMesin;

	@Column(name = "ObjectIpsrsPemakaianMesinFk", columnDefinition = "CHAR(32)", nullable = false, insertable = false, updatable = false)
	private String ipsrsPemakaianMesinId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectMesinFk")
	@Caption(value = "Mesin")
	private Produk mesin;

	@Column(name = "ObjectMesinFk", nullable = false, insertable = false, updatable = false)
	private Integer mesinId;

	@NotNull(message = "Pemakaian Awal tidak boleh kosong")
	@Caption(value = "Pemakaian Awal")
	@Column(name = "PemakaianAwal", nullable = false)
	private Date pemakaianAwal;

	@NotNull(message = "Pemakaian Awal tidak boleh kosong")
	@Caption(value = "Pemakaian Ahir")
	@Column(name = "PemakaianAhir", nullable = false)
	private Date pemakaianAhir;

	@Caption(value = "Lama Pemakaian")
	@Column(name = "LamaPemakaian", nullable = false)
	private String lamaPemakaian;

}
