WEB开发网
开发学院软件开发Java 再谈compass----集成站内搜索 阅读

再谈compass----集成站内搜索

 2009-09-21 00:00:00 来源:WEB开发网   
核心提示: ProductType.java Java代码@Entity@SearchablepublicclassProductTypeimplementsSerializable{privatestaticfinallongserialVersionUID=8106351120886053881L;/*

ProductType.java

Java代码   

@Entity 
@Searchable 
public class ProductType implements Serializable{ 
 private static final long serialVersionUID = 8106351120886053881L; 
 /** 类别id **/ 
 private Integer typeid; 
 /** 类别名称 **/ 
 private String name; 
 /** 子类别 **/ 
 private Set<ProductType> childtypes = new HashSet<ProductType>(); 
 /** 所属父类 **/ 
 private ProductType parent; 
 
 private Set<ProductInfo> products = new HashSet<ProductInfo>(); 
 
 @OneToMany(mappedBy="type", cascade=CascadeType.REMOVE) 
 @SearchableReference 
 public Set<ProductInfo> getProducts() { 
 return products; 
 } 
 
 public void setProducts(Set<ProductInfo> products) { 
 this.products = products; 
 } 
 
 public ProductType() {} 
 
 
 @ManyToOne(cascade=CascadeType.REFRESH) 
 @JoinColumn(name="parentid") 
 public ProductType getParent() { 
 return parent; 
 } 
 
 public void setParent(ProductType parent) { 
 this.parent = parent; 
 } 
 @OneToMany(cascade={CascadeType.REFRESH,CascadeType.REMOVE},mappedBy="parent") 
 public Set<ProductType> getChildtypes() { 
 return childtypes; 
 } 
 
 public void setChildtypes(Set<ProductType> childtypes) { 
 this.childtypes = childtypes; 
 } 
 
 @Column(length=36,nullable=false) 
 public String getName() { 
 return name; 
 } 
 
 public void setName(String name) { 
 this.name = name; 
 } 
 
 @Id @GeneratedValue(strategy=GenerationType.AUTO) 
 @SearchableId 
 public Integer getTypeid() { 
 return typeid; 
 } 
 
 public void setTypeid(Integer typeid) { 
 this.typeid = typeid; 
 } 
 
 @Override 
 public int hashCode() { 
 final int prime = 31; 
 int result = 1; 
 result = prime * result + ((typeid == null) ? 0 : typeid.hashCode()); 
 return result; 
 } 
 
 @Override 
 public boolean equals(Object obj) { 
 if (this == obj) 
  return true; 
 if (obj == null) 
  return false; 
 if (getClass() != obj.getClass()) 
  return false; 
 final ProductType other = (ProductType) obj; 
 if (typeid == null) { 
  if (other.typeid != null) 
  return false; 
 } else if (!typeid.equals(other.typeid)) 
  return false; 
 return true; 
 } 
} 

上一页  1 2 3 4 5 6 7  下一页

Tags:compass 集成 搜索

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接