Convert Hibernate @Formula to JOOQ field

会有一股神秘感。 提交于 2019-12-02 11:26:03

问题


I am rewriting entire DB access layer from Hibernate to JOOQ and I face following issue.

One of JPA models is annotated with @Formula annotation as follows:

@Formula("fee1 + fee2 + fee3 + fee4")
private BigDecimal fee5;

Later in the code, a JPA query is made against the database which compares fee5 to parameter:

SELECT ... FROM ... WHERE fee5 > input;

How can above query be translated to JOOQ DSL?


回答1:


I managed to resolve the issue with following JOOQ query:

BigDecimal input = ...;
Field<BigDecimal> fee5 = TABLE.FEE1.add(TABLE.FEE2).add(TABLE.FEE3).add(TABLE.FEE4).as("fee5");
Condition cond = fee5.greaterThan(input);


来源:https://stackoverflow.com/questions/28166107/convert-hibernate-formula-to-jooq-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!