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 static javax.persistence.CascadeType.ALL;
import static javax.persistence.FetchType.LAZY;

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

	@JsonBackReference
	@OneToOne(cascade = ALL, fetch = LAZY, mappedBy = "ipsrsMaintenance")
	private IpsrsPemeliharaan ipsrsPemeliharaan;

	@JsonBackReference
	@OneToOne(cascade = ALL, fetch = LAZY, mappedBy = "ipsrsMaintenance")
	private IpsrsKontakService ipsrsKontakService;

	@JsonBackReference
	@OneToOne(cascade = ALL, fetch = LAZY, mappedBy = "ipsrsMaintenance")
	private IpsrsKalibrasi ipsrsKalibrasi;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectRuanganFk")
	@Caption(value = "Ruangan")
	private Ruangan ruangan;

	@Column(name = "ObjectRuanganFk", insertable = false, updatable = false)
	private Integer ruanganId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectRegistrasiAsetFk")
	@Caption(value = "Registrasi Aset")
	private RegistrasiAset registrasiAset;

	@Column(name = "ObjectRegistrasiAsetFk", columnDefinition = "CHAR(32)", insertable = false, updatable = false)
	private String registrasiAsetId;

}
