1 package org.hibernate.test.annotations.inheritance; 3 4 import javax.persistence.Entity; 5 import javax.persistence.Id; 6 import javax.persistence.Inheritance; 7 import javax.persistence.InheritanceType; 8 9 12 @Entity() 13 @Inheritance( 14 strategy=InheritanceType.JOINED 15 ) 16 public class Vegetable { 17 private VegetablePk id; 18 private long priceInCent; 19 20 @Id 21 public VegetablePk getId() { 22 return id; 23 } 24 25 public void setId(VegetablePk id) { 26 this.id = id; 27 } 28 29 public long getPriceInCent() { 30 return priceInCent; 31 } 32 33 public void setPriceInCent(long priceInCent) { 34 this.priceInCent = priceInCent; 35 } 36 37 public boolean equals(Object o) { 38 if (this == o) return true; 39 if (!(o instanceof Vegetable)) return false; 40 41 final Vegetable vegetable = (Vegetable) o; 42 43 if (!id.equals(vegetable.id)) return false; 44 45 return true; 46 } 47 48 public int hashCode() { 49 return id.hashCode(); 50 } 51 } 52 | Popular Tags |