package de.hsadmin.mods.pac; import static javax.persistence.FetchType.EAGER; import java.io.Serializable; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.IdClass; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; @Entity(name = "PacComponents") @Table(name = "packet_component") @IdClass(PacComponentId.class) public class PacComponent implements Serializable { private static final long serialVersionUID = 5359873462163274873L; @Id private Pac pac; @Id private BaseComponent baseComponent; @JoinColumn(name = "basepacket_id", columnDefinition = "integer", nullable = false) @ManyToOne(fetch = EAGER) private BasePac basePac; @Column(name = "quantity", columnDefinition = "integer") private int quantity; @Column(name = "created", columnDefinition = "date", nullable = true) @Temporal(TemporalType.DATE) private Date created; @Column(name = "cancelled", columnDefinition = "date", nullable = true) @Temporal(TemporalType.DATE) private Date cancelled; public PacComponent() { } public PacComponent(BasePac basePac, BaseComponent baseComp, Pac pac, int quantity, Date created, Date cancelled) { this.basePac = basePac; this.pac = pac; this.baseComponent = baseComp; this.quantity = quantity; this.created = created; this.cancelled = cancelled; } public BasePac getBasePac() { return basePac; } public void setbasePac(BasePac basePac) { this.basePac = basePac; } public BaseComponent getBaseComponent() { return baseComponent; } public void setBaseComponent(BaseComponent baseComponent) { this.baseComponent = baseComponent; } public Pac getPac() { return pac; } public void setPac(Pac pac) { this.pac = pac; } public int getQuantity() { return quantity; } public void setQuantity(int quantity) { this.quantity = quantity; } public Date getCreated() { return created; } public void setCreated(Date created) { this.created = created; } public Date getCancelled() { return cancelled; } public void setCancelled(Date cancelled) { this.cancelled = cancelled; } }