alternative of @formula in jpa

前端 未结 3 907
春和景丽
春和景丽 2021-01-04 04:15

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          


        
相关标签:
3条回答
  • 2021-01-04 04:35

    You can use a database view that includes the formula, and map the Entity to the view.

    0 讨论(0)
  • 2021-01-04 04:37

    you can use combination of annotations and one method

    @Transient
    private Boolean isDefault;
    
    @PostLoad
    private void setDefault() {
    this.isDefault=this.defaultAirportCode.equals(this.airportCode);
    }
    
    0 讨论(0)
  • 2021-01-04 04:40

    No, there is no pure JPA alternative for @formula annotation.

    0 讨论(0)
提交回复
热议问题