package com.jasonrudolph.ejb3example.entity; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; @Entity @Table(name = "computers") public class ComputerBean implements Serializable { /** The primary key for this computer. */ private int id; /** The serial number for this computer. */ private String serialNumber; /** The company responsible for hardware failures. */ private String brand; /** The model of this computer (e.g., Atari 800XL). */ private String model; /** The employee to which this computer is assigned. */ private EmployeeBean employeeBean; public ComputerBean() { } public ComputerBean(String serialNumber, String brand, String model) { this.serialNumber = serialNumber; this.brand = brand; this.model = model; } /** * @return the system-generated primary key for this computer */ @Id @GeneratedValue public int getId() { return this.id; } /** * Sets the primary key for this computer. Only the EJB container should * invoke this method. * * @param id * the primary key for this computer */ public void setId(int id) { this.id = id; } public String getBrand() { return brand; } public void setBrand(String brand) { this.brand = brand; } public String getModel() { return model; } public void setModel(String model) { this.model = model; } @Column(name = "serial_number") public String getSerialNumber() { return serialNumber; } public void setSerialNumber(String serialNumber) { this.serialNumber = serialNumber; } @ManyToOne(optional = false) @JoinColumn(name = "employee_id") public EmployeeBean getEmployeeBean() { return this.employeeBean; } public void setEmployeeBean(EmployeeBean employee) { this.employeeBean = employee; } }