1 package org.hibernate.ejb.test; 3 4 import java.util.HashSet ; 5 import java.util.Set ; 6 import javax.persistence.Column; 7 import javax.persistence.Entity; 8 import javax.persistence.EntityResult; 9 import javax.persistence.FieldResult; 10 import javax.persistence.Id; 11 import javax.persistence.OneToMany; 12 import javax.persistence.SqlResultSetMapping; 13 14 17 @Entity(name = "Item") 18 @SqlResultSetMapping(name = "getItem", entities = 19 @EntityResult(name = "org.hibernate.ejb.test.Item", fields = { 20 @FieldResult(name = "name", column = "itemname"), 21 @FieldResult(name = "descr", column = "itemdescription") 22 }) 23 ) 24 public class Item { 26 27 private String name; 28 private String descr; 29 private Set <Distributor> distributors; 30 31 public Item() { 32 } 33 34 public Item(String name, String desc) { 35 this.name = name; 36 this.descr = desc; 37 } 38 39 @Column(length = 200) 40 public String getDescr() { 41 return descr; 42 } 43 44 public void setDescr(String desc) { 45 this.descr = desc; 46 } 47 48 @Id @Column(length = 30) 49 public String getName() { 50 return name; 51 } 52 53 public void setName(String name) { 54 this.name = name; 55 } 56 57 @OneToMany 58 public Set <Distributor> getDistributors() { 59 return distributors; 60 } 61 62 public void setDistributors(Set <Distributor> distributors) { 63 this.distributors = distributors; 64 } 65 66 public void addDistributor(Distributor d) { 67 if ( distributors == null ) distributors = new HashSet (); 68 distributors.add( d ); 69 } 70 } 71 | Popular Tags |