jpa中@formula的替代方案 [英] alternative of @formula in jpa

查看:386
本文介绍了jpa中@formula的替代方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过jpa来使用它,例如:

Is there any alternative sollution for @formula which is using in hibernate? I need to use it by jpa, for instance:

@Formula("select count(1) from Market m where m.defaultAirportCode=airportCode")
private Boolean isDefault;


推荐答案

您可以使用注释和一种方法的组合



you can use combination of annotations and one method

@Transient
private Boolean isDefault;

@PostLoad
private void setDefault() {
this.isDefault=this.defaultAirportCode.equals(this.airportCode);
}

这篇关于jpa中@formula的替代方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆