对于entity有些get方法是不需要和数据库关联的。需要用@Transient 注解
比如
@Transient
String getLengthInMeter() { ... } //transient property
@Transient
public String getReviewstatusDesc(){
if(reviewstatus==null){
return "";
}else if("1".equals(reviewstatus)){
return "安排评审";
}else if("2".equals(reviewstatus)){
return "已评审结束";
}else if("0".equals(reviewstatus)){
return "待安排";
}else {
return "";
}
}
@Transient
public String getFundconclusionDesc(){
if(fundconclusion==null){
return "";
}else if("1".equals(fundconclusion)){
return "通过";
}
else if("0".equals(fundconclusion)){
return "暂不资助";
}else {
return "";
}
}
官方hibernate3.5 annotation参考手册 对此属性有如下说明:
Every non static non transient property (field or method depending on the access type) of an entity
is considered persistent, unless you annotate it as @Transient. Not having an annotation for your
property is equivalent to the appropriate @Basic annotation. The @Basic annotation allows you to
declare the fetching strategy for a property