com.avaje.ebean.Query.findUnique()方法的使用及代码示例

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

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

Query.findUnique介绍

[英]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 PersistenceException 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... 
Product product = 
Ebean.find(Product.class) 
.where("sku = ?") 
.set(1, "aa113") 
.findUnique(); 
...

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... 
Order order =  
Ebean.find(Order.class) 
.setId(1) 
.fetch("details") 
.findUnique(); 
List<OrderDetail> details = order.getDetails(); 
...

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

// assuming the sku of products is unique... 
Product product = 
Ebean.find(Product.class) 
.where("sku = ?") 
.set(1, "aa113") 
.findUnique(); 
...

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

// Fetch order 1 and additionally fetch join its order details... 
Order order =  
Ebean.find(Order.class) 
.setId(1) 
.fetch("details") 
.findUnique(); 
List<OrderDetail> details = order.getDetails(); 
...

代码示例

代码示例来源:origin: org.avaje/ebean

public T findUnique() {
  return rootQuery.findUnique();
}

代码示例来源:origin: org.avaje.ebean/ebean

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

代码示例来源:origin: org.avaje.ebean/ebean

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

代码示例来源:origin: org.avaje/ebean

public T findUnique() {
 return query.findUnique();
}

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

public MODEL_TYPE findOne() {
  return qReadOnly.findUnique();
}

代码示例来源:origin: org.avaje.ebeanorm/avaje-ebeanorm-server

public T findUnique() {
  return rootQuery.findUnique();
}

代码示例来源:origin: org.avaje.ebeanorm/avaje-ebeanorm-server

public T findUnique() {
 return query.findUnique();
}

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

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

代码示例来源:origin: com.typesafe.play/play-java-ebean

/**
 * Executes the query and returns the results as either a single bean or <code>null</code>, if no matching bean is found.
 */
public T findUnique() {
  return query().findUnique();
}

代码示例来源:origin: org.avaje.ebeanorm/avaje-ebeanorm-server

query.select(idNames).setId(id);
ref = query.findUnique();

代码示例来源:origin: org.avaje/ebean

query.select(idNames).setId(id);
ref = query.findUnique();

代码示例来源:origin: org.avaje.ebean/ebean

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

相关文章