View Javadoc
1   package myorg.entityex.annotated;
2   
3   import java.math.BigDecimal;
4   import java.util.Date;
5   
6   import org.slf4j.Logger;
7   import org.slf4j.LoggerFactory;
8   
9   @javax.persistence.Entity
10  @javax.persistence.Table(name="ENTITYEX_CAT")
11  @javax.persistence.Access(javax.persistence.AccessType.FIELD)
12  public class Cat2 {
13  	private static final Logger log = LoggerFactory.getLogger(Cat2.class);
14  	@javax.persistence.Id
15  	@javax.persistence.Column(name="CAT_ID")
16  	@javax.persistence.GeneratedValue
17  	private int id;
18  	@javax.persistence.Column(nullable=false, length=20)
19  	private String name;
20  	@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
21  	private Date dob;
22  	private double weight;
23  	
24  	public Cat2() {} //must have default ctor
25  	public Cat2(String name, Date dob, double weight) {
26  		this.name = name;
27  		this.dob = dob;
28  		this.weight = weight;
29  	}
30  	
31  	public int getId() { return id; }
32  	public void setId(int id) {
33  		this.id = id;
34  	}
35  	
36  	public String getName() { return name; }
37  	public void setName(String name) {
38  		this.name = name;
39  	}
40  	
41  	public Date getDob() { return dob; }
42  	public void setDob(Date dob) {
43  		this.dob = dob;
44  	}
45  	
46  	@javax.persistence.Column(precision=3, scale=1)  //10.2lbs
47  	@javax.persistence.Access(javax.persistence.AccessType.PROPERTY)
48  	public BigDecimal getWeight() {
49  		log.debug("annotated.getWeight()");
50  		return new BigDecimal(weight); }
51  	public void setWeight(BigDecimal weight) {
52  		log.debug("annotated.setWeight()");
53  		this.weight = weight==null ? 0 : weight.doubleValue();
54  	}
55  }