package com.jasamedika.medifirst2000.entities;

import com.fasterxml.jackson.annotation.JsonBackReference;
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.sql.Date;

import static javax.persistence.CascadeType.ALL;
import static javax.persistence.FetchType.LAZY;

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

	@NotNull(message = "Tanggal tidak boleh kososng")
	@Caption(value = "Tanggal")
	@Column(name = "Tanggal", nullable = false)
	private Date tanggal;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectPegawaiFk")
	@Caption(value = "Pegawai")
	private Pegawai pegawai;

	@Column(name = "ObjectPegawaiFk", insertable = false, updatable = false)
	private Integer pegawaiId;

	@JsonBackReference
	@OneToOne(cascade = ALL, fetch = LAZY, mappedBy = "ipsrsPemakaianMesin")
	private IpsrsMesinBoiler ipsrsMesinBoiler;

	@JsonBackReference
	@OneToOne(cascade = ALL, fetch = LAZY, mappedBy = "ipsrsPemakaianMesin")
	private IpsrsMesinGenset ipsrsMesinGenset;

}
