hs.hsadmin/hsarback/src/de/hsadmin/mods/pac/PacComponent.java

159 lines
3.2 KiB
Java

package de.hsadmin.mods.pac;
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 {
@Id
@Column(name="packet_id", insertable=false, updatable=false, columnDefinition = "integer")
private long pacId;
@Id
@Column(name="basepacket_id", insertable=false, updatable=false, columnDefinition = "integer")
private long basePacId;
@Id
@Column(name="basecomponent_id", insertable=false, updatable=false, columnDefinition = "integer")
private long baseComponentId;
@ManyToOne
@JoinColumn(name = "packet_id")
private Pac pac;
@ManyToOne
@JoinColumn(name = "basecomponent_id")
private BaseComponent baseComponent;
@ManyToOne
@JoinColumn(name = "basepacket_id")
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;
if (basePac != null) {
this.basePacId = basePac.id();
}
this.pac = pac;
if (pac != null) {
this.pacId = pac.id();
}
this.baseComponent = baseComp;
if (baseComponent != null) {
this.baseComponentId = baseComp.id();
}
this.quantity = quantity;
this.created = created;
this.cancelled = cancelled;
}
public BasePac getBasePac() {
return basePac;
}
public void setbasePac(BasePac basePac) {
this.basePac = basePac;
if (basePac != null) {
this.basePacId = basePac.id();
}
}
public BaseComponent getBaseComponent() {
return baseComponent;
}
public void setBaseComponent(BaseComponent baseComponent) {
this.baseComponent = baseComponent;
if (baseComponent != null) {
this.baseComponentId = baseComponent.id();
}
}
public Pac getPac() {
return pac;
}
public void setPac(Pac pac) {
this.pac = pac;
if (pac != null) {
this.pacId = pac.id();
}
}
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;
}
public void setPacId(long pacId) {
this.pacId = pacId;
}
public long getPacId() {
return pacId;
}
public void setBaseComponentId(long baseComponentId) {
this.baseComponentId = baseComponentId;
}
public long getBaseComponentId() {
return baseComponentId;
}
public void setBasePacId(long basePacId) {
this.basePacId = basePacId;
}
public long getBasePacId() {
return basePacId;
}
}