package com.jasamedika.medifirst2000.entities;

import com.jasamedika.medifirst2000.base.BaseMaster;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;

import static javax.persistence.FetchType.LAZY;
import static javax.persistence.GenerationType.SEQUENCE;

@Getter
@Setter
@NoArgsConstructor
@Entity
@Table(name = "MappingMesinToProduk_M")
public class Mesin extends BaseMaster {

	public Mesin(Produk mesin, Integer kapasitas, Integer id) {
		super();
		this.mesin = mesin;
		this.kapasitas = kapasitas;
		this.id = id;
	}

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

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

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectSatuanFk")
	private SatuanStandar satuan;

	@Column(name = "ObjectSatuanFk", insertable = false, updatable = false)
	private Integer satuanId;

	@Caption(value = "Kapasitas")
	@Column(name = "Kapasitas")
	private Integer kapasitas;

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

}