io.ebean.Query.findOne()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(227)

本文整理了Java中io.ebean.Query.findOne方法的一些代码示例,展示了Query.findOne的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.findOne方法的具体详情如下:
包路径:io.ebean.Query
类名称:Query
方法名:findOne

Query.findOne介绍

[英]Execute the query returning either a single bean or null (if no matching bean is found).

If more than 1 row is found for this query then a NonUniqueResultException is thrown.

This is useful when your predicates dictate that your query should only return 0 or 1 results.

// assuming the sku of products is unique...

It is also useful with finding objects by their id when you want to specify further join information.

// Fetch order 1 and additionally fetch join its order details...

[中]执行查询,返回单个bean或null(如果没有找到匹配的bean)。
如果为该查询找到了超过1行,则会引发UnuniquereSultException。
当谓词规定查询只应返回0或1个结果时,这非常有用。

// assuming the sku of products is unique...

当需要指定进一步的连接信息时,通过对象id查找对象也很有用。

// Fetch order 1 and additionally fetch join its order details...

代码示例

代码示例来源:origin: ebean-orm/ebean

@Override
public T findOne() {
 return query.findOne();
}

代码示例来源:origin: ebean-orm/ebean

@Override
public T findOne() {
 return rootQuery.findOne();
}

代码示例来源:origin: org.actframework/act-ebean

@Override
public MODEL_TYPE findOne() {
  return qReadOnly.findOne();
}

代码示例来源:origin: org.actframework/act-ebean2

@Override
public MODEL_TYPE first() {
  return q.findOne();
}

代码示例来源:origin: io.ebean/ebean

@Override
public T findOne() {
 return query.findOne();
}

代码示例来源:origin: io.ebean/ebean

@Override
public T findOne() {
 return rootQuery.findOne();
}

代码示例来源:origin: org.actframework/act-ebean2

@Override
public MODEL_TYPE findOne() {
  return q.findOne();
}

代码示例来源:origin: io.github.hexagonframework.data/spring-data-ebean

@SuppressWarnings("unchecked")
<E> E findOne() {
  if (queryType == QUERY) {
    return ((Query<E>) queryInstance).findOne();
  }
  throw new IllegalArgumentException("query not supported!");
}

代码示例来源:origin: hexagonframework/spring-data-ebean

@SuppressWarnings("unchecked")
<E> E findOne() {
  if (queryType == QUERY) {
    return ((Query<E>) queryInstance).findOne();
  }
  throw new IllegalArgumentException("query not supported!");
}

代码示例来源:origin: ebean-orm/ebean

return find(type).select(idProp.getName()).setId(id).findOne();

代码示例来源:origin: icode/ameba

/**
 * Executes the query and returns the results as either a single bean or <code>null</code>, if no matching bean is found.
 *
 * @return a M object.
 */
@SuppressWarnings("unchecked")
public <M extends T> M findOne() {
  return (M) query().findOne();
}

代码示例来源:origin: nz.net.osnz.common/common-ebean

public T findBy(Consumer<Query> consumer) {
  return buildQuery(consumer).findOne();
}

代码示例来源:origin: io.ebean/ebean-querybean

return query.findOne();

代码示例来源:origin: icode/ameba

/**
 * find history as of timestamp
 *
 * @param id   model id
 * @param asOf Timestamp
 * @return history model
 * @throws java.lang.Exception any error
 */
public Response fetchHistoryAsOf(@PathParam("id") URI_ID id,
                 @PathParam("asof") final Timestamp asOf) throws Exception {
  final MODEL_ID mId = tryConvertId(id);
  matchedFetchHistoryAsOf(mId, asOf);
  final Query<MODEL> query = server.find(modelType);
  defaultFindOrderBy(query);
  Object entity = executeTx(t -> {
    configDefaultQuery(query);
    configFetchHistoryAsOfQuery(query, mId, asOf);
    applyUriQuery(query, false);
    MODEL model = query.asOf(asOf).setId(mId).findOne();
    return processFetchedHistoryAsOfModel(mId, model, asOf);
  });
  if (isEmptyEntity(entity)) {
    return Response.noContent().build();
  }
  return Response.ok(entity).build();
}

代码示例来源:origin: icode/ameba

model = executeTx(t -> {
  configureQuery.run(t);
  MODEL m = query.setId(firstId).findOne();
  return processFoundByIdModel(m, includeDeleted);
});

代码示例来源:origin: io.ebean/ebean

return find(type).select(idProp.getName()).setId(id).findOne();

相关文章

Query类方法