再谈compass----集成站内搜索
2009-09-21 00:00:00 来源:WEB开发网ProductStyle.java
Java代码
@Entity
@Searchable
public class ProductStyle implements Serializable{
private static final long serialVersionUID = -4926119953511144279L;
private Integer id;
/** 样式的名称 **/
private String name;
/** 图片 **/
private String imagename;
private String image140FullPath;
/** 是否可见 **/
private Boolean visible = true;
private ProductInfo product;
public ProductStyle() {}
public ProductStyle(Integer id) {
this.id = id;
}
public ProductStyle(String name, String imagename) {
this.name = name;
this.imagename = imagename;
}
@ManyToOne(cascade=CascadeType.REFRESH,optional=false)
@JoinColumn(name="productid")
@SearchableReference
public ProductInfo getProduct() {
return product;
}
public void setProduct(ProductInfo product) {
this.product = product;
}
@Id @GeneratedValue
@SearchableId
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(length=30,nullable=false)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(length=40,nullable=false)
@SearchableProperty(index = Index.UN_TOKENIZED, store = Store.YES)
public String getImagename() {
return imagename;
}
public void setImagename(String imagename) {
this.imagename = imagename;
}
@Column(nullable=false)
public Boolean getVisible() {
return visible;
}
public void setVisible(Boolean visible) {
this.visible = visible;
}
@Transient
public String getImageFullPath(){
return "/images/product/"+ this.getProduct().getType().getTypeid()+ "/"+
this.getProduct().getId()+ "/prototype/"+ this.imagename;
}
@Transient
public String getImage140FullPath(){
image140FullPath = "/images/product/"+ this.getProduct().getType().getTypeid()+ "/"+
this.getProduct().getId()+ "/140x/"+ this.imagename;
return image140FullPath;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.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 ProductStyle other = (ProductStyle) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}
更多精彩
赞助商链接