如何在计算字段上对primefaces lazy数据表进行排序

时间:2017-10-08 00:14:48

标签: hibernate primefaces jsf-2 lazy-loading

我有一个实体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"} />

请帮忙。

0 个答案:

没有答案