本文整理了Java中io.ebean.Query.setId
方法的一些代码示例,展示了Query.setId
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setId
方法的具体详情如下:
包路径:io.ebean.Query
类名称:Query
方法名:setId
[英]Set the Id value to query. This is used with findOne().
You can use this to have further control over the query. For example adding fetch joins.
Order order =
[中]设置要查询的Id值。这与findOne()一起使用。
您可以使用它来进一步控制查询。例如,添加fetch连接。
Order order =
代码示例来源:origin: ebean-orm/ebean
@Override
public <T> T publish(Class<T> beanType, Object id, Transaction transaction) {
Query<T> query = find(beanType).setId(id);
List<T> liveBeans = publish(query, transaction);
return (liveBeans.size() == 1) ? liveBeans.get(0) : null;
}
代码示例来源:origin: ebean-orm/ebean
@Override
public <T> T draftRestore(Class<T> beanType, Object id, Transaction transaction) {
Query<T> query = find(beanType).setId(id);
List<T> beans = draftRestore(query, transaction);
return (beans.size() == 1) ? beans.get(0) : null;
}
代码示例来源:origin: ebean-orm/ebean
@Override
public boolean exists(Class<?> beanType, Object beanId, Transaction transaction) {
List<Object> ids = findIds(find(beanType).setId(beanId), transaction);
return !ids.isEmpty();
}
代码示例来源:origin: ebean-orm/ebean
@Override
public ExpressionList<T> idEq(Object value) {
if (query != null && parentExprList == null) {
query.setId(value);
} else {
add(expr.idEq(value));
}
return this;
}
代码示例来源:origin: ebean-orm/ebean
/**
* Find an entity by ID returning an Optional.
*/
@Nullable
public Optional<T> findByIdOrEmpty(I id) {
return db().find(type).setId(id).findOneOrEmpty();
}
代码示例来源:origin: ebean-orm/ebean
@Override
public Set<Property> checkUniqueness(Object bean, Transaction transaction) {
EntityBean entityBean = checkEntityBean(bean);
BeanDescriptor<?> beanDesc = getBeanDescriptor(entityBean.getClass());
BeanProperty idProperty = beanDesc.getIdProperty();
// if the ID of the Property is null we are unable to check uniqueness
if (idProperty == null) {
return Collections.emptySet();
}
Object id = idProperty.getVal(entityBean);
if (entityBean._ebean_getIntercept().isNew() && id != null) {
// Primary Key is changeable only on new models - so skip check if we are not
// new.
Query<?> query = new DefaultOrmQuery<>(beanDesc, this, expressionFactory);
query.setId(id);
if (findCount(query, transaction) > 0) {
Set<Property> ret = new HashSet<>();
ret.add(idProperty);
return ret;
}
}
for (BeanProperty[] props : beanDesc.getUniqueProps()) {
Set<Property> ret = checkUniqueness(entityBean, beanDesc, props, transaction);
if (ret != null) {
return ret;
}
}
return Collections.emptySet();
}
代码示例来源:origin: org.actframework/act-ebean
@Override
public EbeanQuery<MODEL_TYPE> setId(Object id) {
q.setId(id);
qReadOnly.setId(id);
return this;
}
代码示例来源:origin: org.actframework/act-ebean2
@Override
public EbeanQuery<MODEL_TYPE> setId(Object id) {
q.setId(id);
return this;
}
代码示例来源:origin: ebean-orm/ebean
/**
* Fetch the outline bean with associated one and associated many beans loaded with Id values only.
* <p>
* We use the Id values to determine what are inserts, updates and deletes as part of the merge.
*/
private EntityBean fetchOutline(Set<String> paths) {
Query<?> query = server.find(desc.getBeanType());
query.setBeanCacheMode(CacheMode.OFF);
query.setPersistenceContextScope(PersistenceContextScope.QUERY);
query.setId(desc.getId(bean));
query.select(desc.getIdProperty().getName());
for (String path : paths) {
MergeNode node = buildNode(path);
node.addSelectId(query);
}
return (EntityBean) server.findOne(query, transaction);
}
代码示例来源:origin: io.ebean/ebean-querybean
/**
* Set the Id value to query. This is used with findOne().
* <p>
* You can use this to have further control over the query. For example adding
* fetch joins.
* </p>
* <p>
* <pre>{@code
*
* Order order =
* new QOrder()
* .setId(1)
* .fetch("details")
* .findOne();
*
* // the order details were eagerly fetched
* List<OrderDetail> details = order.getDetails();
*
* }</pre>
*/
public R setId(Object id) {
query.setId(id);
return root;
}
代码示例来源:origin: ebean-orm/ebean
return find(type).select(idProp.getName()).setId(id).findOne();
代码示例来源:origin: icode/ameba
/**
* {@inheritDoc}
* Sets the ID value to query.
*/
public Query<T> setId(Object id) {
return query().setId(id);
}
代码示例来源:origin: io.ebean/ebean
@Override
public <T> T publish(Class<T> beanType, Object id, Transaction transaction) {
Query<T> query = find(beanType).setId(id);
List<T> liveBeans = publish(query, transaction);
return (liveBeans.size() == 1) ? liveBeans.get(0) : null;
}
代码示例来源:origin: io.ebean/ebean
@Override
public <T> T draftRestore(Class<T> beanType, Object id, Transaction transaction) {
Query<T> query = find(beanType).setId(id);
List<T> beans = draftRestore(query, transaction);
return (beans.size() == 1) ? beans.get(0) : null;
}
代码示例来源:origin: io.ebean/ebean
@Override
public boolean exists(Class<?> beanType, Object beanId, Transaction transaction) {
List<Object> ids = findIds(find(beanType).setId(beanId), transaction);
return !ids.isEmpty();
}
代码示例来源:origin: io.ebean/ebean
@Override
public ExpressionList<T> idEq(Object value) {
if (query != null && parentExprList == null) {
query.setId(value);
} else {
add(expr.idEq(value));
}
return this;
}
代码示例来源:origin: io.ebean/ebean
/**
* Find an entity by ID returning an Optional.
*/
@Nullable
public Optional<T> findByIdOrEmpty(I id) {
return db().find(type).setId(id).findOneOrEmpty();
}
代码示例来源:origin: io.ebean/ebean
@Override
public Set<Property> checkUniqueness(Object bean, Transaction transaction) {
EntityBean entityBean = checkEntityBean(bean);
BeanDescriptor<?> beanDesc = getBeanDescriptor(entityBean.getClass());
BeanProperty idProperty = beanDesc.getIdProperty();
// if the ID of the Property is null we are unable to check uniqueness
if (idProperty == null) {
return Collections.emptySet();
}
Object id = idProperty.getVal(entityBean);
if (entityBean._ebean_getIntercept().isNew() && id != null) {
// Primary Key is changeable only on new models - so skip check if we are not
// new.
Query<?> query = new DefaultOrmQuery<>(beanDesc, this, expressionFactory);
query.setId(id);
if (findCount(query, transaction) > 0) {
Set<Property> ret = new HashSet<>();
ret.add(idProperty);
return ret;
}
}
for (BeanProperty[] props : beanDesc.getUniqueProps()) {
Set<Property> ret = checkUniqueness(entityBean, beanDesc, props, transaction);
if (ret != null) {
return ret;
}
}
return Collections.emptySet();
}
代码示例来源: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: io.ebean/ebean
/**
* Fetch the outline bean with associated one and associated many beans loaded with Id values only.
* <p>
* We use the Id values to determine what are inserts, updates and deletes as part of the merge.
*/
private EntityBean fetchOutline(Set<String> paths) {
Query<?> query = server.find(desc.getBeanType());
query.setBeanCacheMode(CacheMode.OFF);
query.setPersistenceContextScope(PersistenceContextScope.QUERY);
query.setId(desc.getId(bean));
query.select(desc.getIdProperty().getName());
for (String path : paths) {
MergeNode node = buildNode(path);
node.addSelectId(query);
}
return (EntityBean) server.findOne(query, transaction);
}
内容来源于网络,如有侵权,请联系作者删除!