我有一个实体Foo和ABC。
@Entity
public class Foo{
@Id
@Column
private int id;
@Column
private Double amount;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ABC_ID")
@Getter
@Setter
private ABC abc;
//calculated dervived field which needs to be called in primefaces
private totalAmount;
}
现在数学totalAmount
计算如下:
totalAMOunt = amount + (amount*abc.rate)
我如何在Hiberate映射中执行此操作?我可以映射第二个表格列并使用@Formula
吗?
它将在primefaces中调用
<p:column sortBy=#{"foo.totalAmount"} />
请帮忙。