【发布时间】:2018-05-24 08:19:24
【问题描述】:
我是 jOOQ 的新手,我必须将查询翻译成 jOOQ;
我的“CN_THEODOINO”表包含两个字段:NAM(表示 YEAR)和 THANG(表示 MONTH),数据类型为 short 和 byte。
我想计算该表中 sysdate 与 NAM 和 THANG 之间的不同月份。
之后,我将与我的参数中的 p_diff 进行比较并选择大于它的那些。
我试试这个:
public List<CN_DS_NO> layDsKHangNo3(String sInputParam) throws JSONException {
try {
Calendar c = Calendar.getInstance();
int currMonths = c.get(Calendar.YEAR) * 12 + c.get(Calendar.MONTH);
JSONObject jsonObj = new JSONObject(sInputParam);
short p_diff = (short)jsonObj.getInt("SO_THANGNO");
Condition condition = DSL.trueCondition();
condition = condition.and(bangDsChuyenNo2.TIEN_NO.gt(Long.valueOf(0)));
condition = condition.and(bangDsChuyenNo2.NAM.mul(12).add(bangDsChuyenNo2.THANG).add(p_diff).sub(currMonths).lessOrEqual((short)0));
condition = condition.groupBy(bangDsChuyenNo2.MA_KHANG);
condition = condition.having(DSL.count(bangDsChuyenNo2.ID_HDON).gt(jsonObj.getInt("SO_HOADON")).and(DSL.sum((Field) field(bangDsChuyenNo2.TIEN_NO)).gt(jsonObj.getLong("TONG_NO"))));
qDsChuyenNo = this.getCreate()
.select()
.from(bangDsChuyenNo)
.where(condition);
return nativeQuery(this.getEm(), qDsChuyenNo, CN_DS_NO.class);
} catch (Exception ex) {
throw ex;
}
我得到两个错误,比如说:
错误(141,34):找不到符号;符号:方法 groupBy(org.jooq.TableField); location:org.jooq.Condition 类型的变量条件
错误(142,34):找不到符号;符号:方法有(org.jooq.Condition); location:org.jooq.Condition 类型的变量条件
那么我如何在 jOOQ 中做到这一点。我已经在谷歌和我们的论坛中搜索过,但无法得到答案。请帮帮我。
【问题讨论】: