From aec92d8be841d05286276148b5433b94b6f3b863 Mon Sep 17 00:00:00 2001 From: Martin Goik <goik@hdm-stuttgart.de> Date: Thu, 2 May 2013 22:33:00 +0200 Subject: [PATCH] No Laptop needed in Employee <--> Project discussion --- .../java/entity/company7/model/Laptop.java | 63 ------------------- 1 file changed, 63 deletions(-) delete mode 100644 ws/eclipse/HibIntro/src/main/java/entity/company7/model/Laptop.java diff --git a/ws/eclipse/HibIntro/src/main/java/entity/company7/model/Laptop.java b/ws/eclipse/HibIntro/src/main/java/entity/company7/model/Laptop.java deleted file mode 100644 index fd7d7f89f..000000000 --- a/ws/eclipse/HibIntro/src/main/java/entity/company7/model/Laptop.java +++ /dev/null @@ -1,63 +0,0 @@ -package entity.company7.model; - -import javax.persistence.CascadeType; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.OneToOne; -import javax.persistence.Table; -import javax.persistence.UniqueConstraint; - - -/** - * - * Laptops possibly being assigned to {@link Employee} - * - */ -@Entity -@Table(uniqueConstraints={@UniqueConstraint(columnNames={"idNumber"})}) -public class Laptop { - - @Id - @GeneratedValue - public Long getId() {return id;} - protected void setId(Long id) {this.id = id;} - private Long id; - - /** - * @return The device's unique part number - */ - public int getIdNumber() { return idNumber;} - public void setIdNumber(int idNumber) { this.idNumber = idNumber;} - int idNumber; - - @OneToOne (mappedBy="laptop",cascade={CascadeType.ALL}) - public Employee getOwner() { return owner;} - - public void setOwner(Employee owner) { - if (getOwner() == owner) { return;} - if (null != getOwner()) { getOwner().setLaptopInternal(null);} - setOwnerInternal(owner); - if (null != getOwner()) { getOwner().setLaptopInternal(this);} - } - protected void setOwnerInternal(Employee owner) { this.owner = owner;} - Employee owner; - - protected Laptop(){} - - public Laptop(final int idNumber) { - setIdNumber(idNumber); - } - @Override - public boolean equals(Object other) { - if (this == other) { - return true; - } else if (other instanceof Laptop) { - return this.getIdNumber() == ((Laptop) other).getIdNumber(); - } else { - return false; - } - } - @Override - public int hashCode() { return getIdNumber();} -} \ No newline at end of file -- GitLab