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?
Advertisement
Answer
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);