Jooq比较偏的用法

count

  public Integer count(Integer id) {
    return dslContext.selectCount().from(Tables.<table_name>)
        .where(Tables.<table_name>.ID.eq(id)).fetchOne(0, Integer.class);
  }

like   order by case when then  按照匹配度排序

  public List<<table_name>> searchSymptomsByKey(String keyStr) {
    String key = keyStr.replace("%", "");
    return dslContext.select().from(Tables.<table_name>)
        .where(Tables.<table>.<filed>.like(keyStr))
        .orderBy(DSL.decode().when(Tables.<table_name>.<field>.like(key), 0)
            .when(Tables.<table_name>.<filed>.like("%" + key), 1)
            .when(Tables.<table_name>.<field>.like("%" + key + "%"), 2).otherwise(3).asc())
        .fetchInto(<table_name>.class);
  }

为true的Condition

Condition condition = DSL.trueCondition();

 

posted @ 2017-03-01 17:07  bad_boy_f  阅读(1954)  评论(0编辑  收藏  举报