Advertisement
Guest User

entity.Userorder

a guest
Feb 17th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.97 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package entity;
  6.  
  7. import java.io.Serializable;
  8. import java.math.BigDecimal;
  9. import java.util.Date;
  10. import java.util.List;
  11. import javax.persistence.Basic;
  12. import javax.persistence.CascadeType;
  13. import javax.persistence.Column;
  14. import javax.persistence.Entity;
  15. import javax.persistence.GeneratedValue;
  16. import javax.persistence.GenerationType;
  17. import javax.persistence.Id;
  18. import javax.persistence.JoinColumn;
  19. import javax.persistence.ManyToOne;
  20. import javax.persistence.NamedQueries;
  21. import javax.persistence.NamedQuery;
  22. import javax.persistence.OneToMany;
  23. import javax.persistence.Table;
  24. import javax.persistence.Temporal;
  25. import javax.persistence.TemporalType;
  26. import javax.validation.constraints.NotNull;
  27. import javax.xml.bind.annotation.XmlRootElement;
  28. import javax.xml.bind.annotation.XmlTransient;
  29.  
  30. /**
  31. *
  32. * @author kelto
  33. */
  34. @Entity
  35. @Table(name = "User_order")
  36. @XmlRootElement
  37. @NamedQueries({
  38. @NamedQuery(name = "Userorder.findAll", query = "SELECT u FROM Userorder u"),
  39. @NamedQuery(name = "Userorder.findById", query = "SELECT u FROM Userorder u WHERE u.id = :id"),
  40. @NamedQuery(name = "Userorder.findByAmount", query = "SELECT u FROM Userorder u WHERE u.amount = :amount"),
  41. @NamedQuery(name = "Userorder.findByDateCreated", query = "SELECT u FROM Userorder u WHERE u.dateCreated = :dateCreated"),
  42. @NamedQuery(name = "Userorder.findByConfirmationNumber", query = "SELECT u FROM Userorder u WHERE u.confirmationNumber = :confirmationNumber")})
  43. public class Userorder implements Serializable {
  44. private static final long serialVersionUID = 1L;
  45. @Id
  46. @GeneratedValue(strategy = GenerationType.IDENTITY)
  47. @Basic(optional = false)
  48. @Column(name = "id")
  49. private Integer id;
  50. // @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
  51. @Basic(optional = false)
  52. @NotNull
  53. @Column(name = "amount")
  54. private BigDecimal amount;
  55. @Basic(optional = false)
  56. @NotNull
  57. @Column(name = "date_created")
  58. @Temporal(TemporalType.TIMESTAMP)
  59. private Date dateCreated;
  60. @Basic(optional = false)
  61. @NotNull
  62. @Column(name = "confirmation_number")
  63. private int confirmationNumber;
  64. @OneToMany(cascade = CascadeType.ALL, mappedBy = "userorderid")
  65. private List<Bill> billList;
  66. @OneToMany(cascade = CascadeType.ALL, mappedBy = "userorder")
  67. private List<OrderedProduct> orderedProductList;
  68. @JoinColumn(name = "User_id", referencedColumnName = "id")
  69. @ManyToOne(optional = false)
  70. private User userid;
  71.  
  72. public Userorder() {
  73. }
  74.  
  75. public Userorder(Integer id) {
  76. this.id = id;
  77. }
  78.  
  79. public Userorder(Integer id, BigDecimal amount, Date dateCreated, int confirmationNumber) {
  80. this.id = id;
  81. this.amount = amount;
  82. this.dateCreated = dateCreated;
  83. this.confirmationNumber = confirmationNumber;
  84. }
  85.  
  86. public Integer getId() {
  87. return id;
  88. }
  89.  
  90. public void setId(Integer id) {
  91. this.id = id;
  92. }
  93.  
  94. public BigDecimal getAmount() {
  95. return amount;
  96. }
  97.  
  98. public void setAmount(BigDecimal amount) {
  99. this.amount = amount;
  100. }
  101.  
  102. public Date getDateCreated() {
  103. return dateCreated;
  104. }
  105.  
  106. public void setDateCreated(Date dateCreated) {
  107. this.dateCreated = dateCreated;
  108. }
  109.  
  110. public int getConfirmationNumber() {
  111. return confirmationNumber;
  112. }
  113.  
  114. public void setConfirmationNumber(int confirmationNumber) {
  115. this.confirmationNumber = confirmationNumber;
  116. }
  117.  
  118. @XmlTransient
  119. public List<Bill> getBillList() {
  120. return billList;
  121. }
  122.  
  123. public void setBillList(List<Bill> billList) {
  124. this.billList = billList;
  125. }
  126.  
  127. @XmlTransient
  128. public List<OrderedProduct> getOrderedProductList() {
  129. return orderedProductList;
  130. }
  131.  
  132. public void setOrderedProductList(List<OrderedProduct> orderedProductList) {
  133. this.orderedProductList = orderedProductList;
  134. }
  135.  
  136. public User getUserid() {
  137. return userid;
  138. }
  139.  
  140. public void setUserid(User userid) {
  141. this.userid = userid;
  142. }
  143.  
  144. @Override
  145. public int hashCode() {
  146. int hash = 0;
  147. hash += (id != null ? id.hashCode() : 0);
  148. return hash;
  149. }
  150.  
  151. @Override
  152. public boolean equals(Object object) {
  153. // TODO: Warning - this method won't work in the case the id fields are not set
  154. if (!(object instanceof Userorder)) {
  155. return false;
  156. }
  157. Userorder other = (Userorder) object;
  158. if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
  159. return false;
  160. }
  161. return true;
  162. }
  163.  
  164. @Override
  165. public String toString() {
  166. return "entity.Userorder[ id=" + id + " ]";
  167. }
  168.  
  169. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement