View Javadoc
1   package ejava.examples.asyncmarket.bo;
2   
3   import java.io.Serializable;
4   
5   import javax.persistence.*;
6   
7   @Entity @Table(name="ASYNCMARKET_BID")
8   public class Bid implements Serializable{
9       private static final long serialVersionUID = 1L;
10      private long id;
11      private double amount;
12      private Person person;
13      private AuctionItem item;
14      
15      public Bid() {}
16      public Bid(long id) {setId(id); }
17      
18      @Id @GeneratedValue
19      public long getId() {
20          return id;
21      }
22      private void setId(long id) {
23          this.id = id;
24      }
25      
26      @Column(scale=7, precision=2)
27      public double getAmount() {
28          return amount;
29      }
30      public void setAmount(double amount) {
31          this.amount = amount;
32      }
33      
34      @ManyToOne
35      public Person getBidder() {
36          return person;
37      }
38      public void setBidder(Person person) {
39          this.person = person;
40      }
41      
42      @ManyToOne
43      public AuctionItem getItem() {
44          return item;
45      }
46      public void setItem(AuctionItem item) {
47          this.item = item;
48      }
49      
50      public String toString() {
51          StringBuilder text = new StringBuilder();
52          text.append("id=" + id);
53          text.append(", bidder=" + (person==null?null:person.getUserId()));
54          text.append(", item=" + (item==null ? null : item.getId()));
55          text.append(", $" + amount);
56          return text.toString();
57      }
58  }