我想在域类中添加一个属性,以便使用类的属性计算某些内容:
@Entity
@Table(name="tablename")
public class MyDomainClass {
int id;
int property1;
int property2;
@Id
@GeneratedValue
@Column(name="id")
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
@Column(name="property1")
public int getProperty1() {
return this.property1;
}
public void setProperty1(int property1) {
this.property1= property1;
}
public int getProperty2() {
;doSomething
return this.property2;
}
public void setProperty2(int property2) {
this.property2= property2;
}
我不希望将property2映射到表“tablename”,但实际上它是。
我该怎么办呢?
我需要从jsp访问此属性,例如domainclass.property2