Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package entity;
- import java.io.Serializable;
- import java.math.BigDecimal;
- import java.util.Date;
- import java.util.List;
- import javax.persistence.Basic;
- import javax.persistence.CascadeType;
- import javax.persistence.Column;
- import javax.persistence.Entity;
- 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.Table;
- import javax.persistence.Temporal;
- import javax.persistence.TemporalType;
- import javax.validation.constraints.NotNull;
- import javax.xml.bind.annotation.XmlRootElement;
- import javax.xml.bind.annotation.XmlTransient;
- /**
- *
- * @author kelto
- */
- @Entity
- @Table(name = "User_order")
- @XmlRootElement
- @NamedQueries({
- @NamedQuery(name = "Userorder.findAll", query = "SELECT u FROM Userorder u"),
- @NamedQuery(name = "Userorder.findById", query = "SELECT u FROM Userorder u WHERE u.id = :id"),
- @NamedQuery(name = "Userorder.findByAmount", query = "SELECT u FROM Userorder u WHERE u.amount = :amount"),
- @NamedQuery(name = "Userorder.findByDateCreated", query = "SELECT u FROM Userorder u WHERE u.dateCreated = :dateCreated"),
- @NamedQuery(name = "Userorder.findByConfirmationNumber", query = "SELECT u FROM Userorder u WHERE u.confirmationNumber = :confirmationNumber")})
- public class Userorder implements Serializable {
- private static final long serialVersionUID = 1L;
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Basic(optional = false)
- @Column(name = "id")
- private Integer id;
- // @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
- @Basic(optional = false)
- @NotNull
- @Column(name = "amount")
- private BigDecimal amount;
- @Basic(optional = false)
- @NotNull
- @Column(name = "date_created")
- @Temporal(TemporalType.TIMESTAMP)
- private Date dateCreated;
- @Basic(optional = false)
- @NotNull
- @Column(name = "confirmation_number")
- private int confirmationNumber;
- @OneToMany(cascade = CascadeType.ALL, mappedBy = "userorderid")
- private List<Bill> billList;
- @OneToMany(cascade = CascadeType.ALL, mappedBy = "userorder")
- private List<OrderedProduct> orderedProductList;
- @JoinColumn(name = "User_id", referencedColumnName = "id")
- @ManyToOne(optional = false)
- private User userid;
- public Userorder() {
- }
- public Userorder(Integer id) {
- this.id = id;
- }
- public Userorder(Integer id, BigDecimal amount, Date dateCreated, int confirmationNumber) {
- this.id = id;
- this.amount = amount;
- this.dateCreated = dateCreated;
- this.confirmationNumber = confirmationNumber;
- }
- public Integer getId() {
- return id;
- }
- public void setId(Integer id) {
- this.id = id;
- }
- public BigDecimal getAmount() {
- return amount;
- }
- public void setAmount(BigDecimal amount) {
- this.amount = amount;
- }
- public Date getDateCreated() {
- return dateCreated;
- }
- public void setDateCreated(Date dateCreated) {
- this.dateCreated = dateCreated;
- }
- public int getConfirmationNumber() {
- return confirmationNumber;
- }
- public void setConfirmationNumber(int confirmationNumber) {
- this.confirmationNumber = confirmationNumber;
- }
- @XmlTransient
- public List<Bill> getBillList() {
- return billList;
- }
- public void setBillList(List<Bill> billList) {
- this.billList = billList;
- }
- @XmlTransient
- public List<OrderedProduct> getOrderedProductList() {
- return orderedProductList;
- }
- public void setOrderedProductList(List<OrderedProduct> orderedProductList) {
- this.orderedProductList = orderedProductList;
- }
- public User getUserid() {
- return userid;
- }
- public void setUserid(User userid) {
- this.userid = userid;
- }
- @Override
- public int hashCode() {
- int hash = 0;
- hash += (id != null ? id.hashCode() : 0);
- return hash;
- }
- @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 Userorder)) {
- return false;
- }
- Userorder other = (Userorder) object;
- if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
- return false;
- }
- return true;
- }
- @Override
- public String toString() {
- return "entity.Userorder[ id=" + id + " ]";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement