Load a single record using JooqTemplate

작성자

카테고리:

← 피드로
DEV Community · ts5432 · 2026-06-11 개발(SW)

ts5432

ts5432

Posted on Jun 11 • Edited on Jun 19

1. load

Load a single record matching the condition and map it to the specified entity class. Automatically appends LIMIT 1.

public <E> E load(String table, Class<E> cls, Condition condition)
public <E> E load(String table, Class<E> cls, Condition condition, List<? extends OrderField> orderBy)
public <E> E load(String table, Class<E> cls, List<Condition> conditions)
public <E> E load(String table, Class<E> cls, List<Condition> conditions, List<? extends OrderField> orderBy)

Enter fullscreen mode Exit fullscreen mode

Returns: Entity object, or null if not found.
Example:

// Single condition
User user = jt.load("user_table", User.class, F("id").eq(id));

// Multiple conditions + order
User user = jt.load("user_table", User.class,
    Arrays.asList(F("name").eq("John"), F("birthday").isNotNull()),
    Arrays.asList(F("create_time").desc()));

Enter fullscreen mode Exit fullscreen mode

2. loadv (varargs conditions)

Load a single record using varargs for conditions. Supports embedding operators and ordering in field names.

public <E> E loadv(String table, Class<E> cls, Object... conditions)
public <E> E loadv(TableLike table, Class<E> cls, Object... conditions)

Enter fullscreen mode Exit fullscreen mode

Example:

// Simple equality
User user = jt.loadv("user_table", User.class, "id", id);

// Combined conditions + sort
User user = jt.loadv("user_table", User.class,
    "name", name, "name:isnotnull", "birthday:desc");

// Mix with Condition object
User user = jt.loadv("user_table", User.class,
    "id", id, F("name").isNotNull());

Enter fullscreen mode Exit fullscreen mode

3. loadRecord

public Record loadRecord(String table, Condition condition)
public Record loadRecord(String table, List<Condition> conditions)
public Record loadRecord(String table, Condition condition, List<? extends OrderField> orderBy)
public Record loadRecord(String table, List<Condition> conditions, List<? extends OrderField> orderBy)
public Record loadRecordv(String table, Object... conditions)

Enter fullscreen mode Exit fullscreen mode

4. loadLowerCaseRecord

public LowerCaseRecord loadLowerCaseRecord(String table, Condition condition)
public LowerCaseRecord loadLowerCaseRecord(String table, List<Condition> conditions)
public LowerCaseRecord loadLowerCaseRecordv(String table, Object... conditions)

Enter fullscreen mode Exit fullscreen mode

원문에서 계속 ↗

코멘트

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다