/* * Usersent.java * * Created on 02 February 2007, 14:42 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ //eve.pokua package machinedetails2; import machinedetails2.*; import java.io.Serializable; import java.util.Collection; import java.util.List; //import java.util.Collection; //import java.util.Collection; //import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EntityManager; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; //import javax.persistence.JoinColumn; //import javax.persistence.JoinTable; //import javax.persistence.ManyToOne; //import javax.persistence.OneToMany; import javax.persistence.Table; //import machinedetails.Machineent; /** * Entity class Usersent * * @author eve.pokua */ @Entity @Table(name="USERS") //@NamedQueries({ //@NamedQuery(name = "Machinedetail2.Usersent.findMachinebyuser",query = "SELECT m, us FROM Usersent us, Machineent m WHERE us.UserID=:UserID AND us.UserID=m.UserID") }) //"SELECT m, us.UserID, us.Firstname, us.Surname FROM Machineent m, Usersent us WHERE us.UserID=:UserID") }) public class Usersent implements Serializable { // @ManyToOne //private Machineent machineent; //@OneToOne(mappedBy = "usersent") // private Machineent machinePCNM; //@Id //@GeneratedValue(strategy = GenerationType.AUTO) //private Long id; @Id @Column(name="USERID", nullable=false, length=8) private String userID; @Column(name="FIRSTNAME", nullable=true, length=60) private String firstname; @Column(name="SURNAME", nullable=true, length=80) private String surname; @Column(name="PASSWORD", nullable=true, length=10) private String password; @OneToMany(mappedBy="usersent") private Collection machineents; // @OneToMany(mappedBy = "usersent") //@ManyToOne() //@JoinColumn(name="comptername") //private Machineent machineent; //@OneToMany(mappedBy = "users") //private Collection machineents; //referencing relationship of usersent and machinesen //@JoinTable(name = "MACHINE_USER", joinColumns = @JoinColumn(name = "COMPUTNAME", referencedColumnName = "COMPUTNAME") //, inverseJoinColumns = @JoinColumn(name = "USERID", referencedColumnName = "USERID") //) //@ManyToOne //private Collection usersent; //@OneToMany(mappedBy = "usersent") //@ManyToOne(mappedBy = "machineent") //private Collection machineent; /** Creates a new instance of Usersent */ public Usersent() { } /**constructor used to retrive the user's login details after login*/ public Usersent(String userID, String password ) { this.userID=userID; this.password=password; } public Usersent(String userID, String firstname, String surname, String password ) { this.userID=userID; this.firstname=firstname; this.surname=surname; this.password=password; } public Usersent(String userid) { } /** * Gets the id of this Usersent. * @return the id */ //public Long getId() { //return this.id; //} /** * Sets the id of this Usersent to the specified value. * @param id the new id */ // public void setId(Long id) { //this.id = id; //} //Create the User table with the following columns //A call to the entity manager will result in //an insertion into the database //EntityManager em; //Constructor for creating an instance of a user public String getUserid() {return userID;} public void setUserid(String UserID){ this.userID=UserID; } public String getFirstname() {return firstname;} public void setFirstname(String firstname){ this.firstname=firstname; } public String getSurname() {return surname;} public void setSurname(String surname){ this.surname=surname; } public String getPassword() {return password;} public void setPassword(String password){ this.password=password; } /** * Returns a hash code value for the object. This implementation computes * a hash code value based on the id fields in this object. * @return a hash code value for this object. */ @Override public int hashCode() { int hash = 0; hash += (this.userID != null ? this.userID.hashCode() : 0); return hash; } /** * Determines whether another object is equal to this Usersent. The result is * true if and only if the argument is not null and is a Usersent object that * has the same id field values as this object. * @param object the reference object with which to compare * @return true if this object is the same as the argument; * false otherwise. */ @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Usersent)) { return false; } Usersent other = (Usersent)object; if (this.userID != other.userID && (this.userID == null || !this.userID.equals(other.userID))) return false; return true; } /** * Returns a string representation of the object. This implementation constructs * that representation based on the id fields. * @return a string representation of the object. */ @Override public String toString() { return "MachineUsers.Usersent[id=" + userID + "]"; } //void add(Usersent usersent) { //throw new UnsupportedOperationException("Not yet implemented"); //} void add(Usersent usersent) { throw new UnsupportedOperationException("Not yet implemented"); } }