1 package org.hibernate.test.filter; 3 4 import java.util.Set ; 5 import java.util.Date ; 6 import java.util.HashSet ; 7 8 11 public class Product { 12 private Long id; 13 private String name; 14 private int stockNumber; private Date effectiveStartDate; 16 private Date effectiveEndDate; 17 private Set orderLineItems; 18 private Set categories; 19 20 public Long getId() { 21 return id; 22 } 23 24 public void setId(Long id) { 25 this.id = id; 26 } 27 28 public String getName() { 29 return name; 30 } 31 32 public void setName(String name) { 33 this.name = name; 34 } 35 36 public Set getOrderLineItems() { 37 return orderLineItems; 38 } 39 40 public void setOrderLineItems(Set orderLineItems) { 41 this.orderLineItems = orderLineItems; 42 } 43 44 public int getStockNumber() { 45 return stockNumber; 46 } 47 48 public void setStockNumber(int stockNumber) { 49 this.stockNumber = stockNumber; 50 } 51 52 public int hashCode() { 53 return stockNumber; 54 } 55 56 public boolean equals(Object obj) { 57 return ( (Product) obj ).stockNumber == this.stockNumber; 58 } 59 60 public Date getEffectiveStartDate() { 61 return effectiveStartDate; 62 } 63 64 public void setEffectiveStartDate(Date effectiveStartDate) { 65 this.effectiveStartDate = effectiveStartDate; 66 } 67 68 public Date getEffectiveEndDate() { 69 return effectiveEndDate; 70 } 71 72 public void setEffectiveEndDate(Date effectiveEndDate) { 73 this.effectiveEndDate = effectiveEndDate; 74 } 75 76 public Set getCategories() { 77 return categories; 78 } 79 80 public void setCategories(Set categories) { 81 this.categories = categories; 82 } 83 84 public void addCategory(Category category) { 85 if ( category == null ) { 86 return; 87 } 88 89 if ( categories == null ) { 90 categories = new HashSet (); 91 } 92 93 categories.add( category ); 94 if ( category.getProducts() == null ) { 95 category.setProducts( new HashSet () ); 96 } 97 category.getProducts().add( this ); 98 } 99 } 100 | Popular Tags |