View Javadoc
1   package ejava.examples.blpurchase.bo;
2   
3   import javax.persistence.Column;
4   import javax.persistence.Entity;
5   import javax.persistence.GeneratedValue;
6   import javax.persistence.Id;
7   import javax.persistence.NamedQueries;
8   import javax.persistence.NamedQuery;
9   import javax.persistence.Table;
10  
11  /**
12   * An account is tracked 
13   */
14  @Entity
15  @Table(name="BLPURCHASE_ACCOUNT")
16  @NamedQueries({
17  	@NamedQuery(name="blPurchasing.findAccountByEmail", 
18  			    query="select a from Account a where a.email=:email")
19  })
20  public class Account {
21  	public static final String FIND_BY_EMAIL_QUERY="blPurchasing.findAccountByEmail";
22  	
23  	@Id @GeneratedValue
24  	private int id;
25  	
26  	@Column(nullable=false, unique=true)
27  	private String email;
28  	
29  	@Column(nullable=false)
30  	private String password;
31  	
32  	@Column(nullable=false)
33  	private String firstName;
34  	
35  	@Column(nullable=false)
36  	private String lastName;
37  
38  	public Account(){}
39  	public Account(String email, String firstName, String lastName) {
40  		this.email = email;
41  		this.firstName = firstName;
42  		this.lastName = lastName;
43  	}
44  	
45  	public int getId() {
46  		return id;
47  	}
48  	protected void setId(int id) {
49  		this.id = id;
50  	}
51  	
52  	public String getEmail() {
53  		return email;
54  	}
55  	public void setEmail(String email) {
56  		this.email = email;
57  	}
58  	
59  	public String getPassword() {
60  		return password;
61  	}
62  	public void setPassword(String password) {
63  		this.password = password;
64  	}
65  	
66  	public String getFirstName() {
67  		return firstName;
68  	}
69  	public void setFirstName(String firstName) {
70  		this.firstName = firstName;
71  	}
72  	
73  	public String getLastName() {
74  		return lastName;
75  	}
76  	public void setLastName(String lastName) {
77  		this.lastName = lastName;
78  	}
79  
80  	@Override
81  	public String toString() {
82  		StringBuilder builder = new StringBuilder();
83  		builder.append("id=").append(id)
84  		       .append(", email=").append(email)
85  			   .append(", firstName=").append(firstName)
86  			   .append(", lastName=").append(lastName);
87  		return builder.toString();
88  	}
89  	
90  	
91  }