本文整理了Java中org.mongodb.morphia.Datastore.getByKey()
方法的一些代码示例,展示了Datastore.getByKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Datastore.getByKey()
方法的具体详情如下:
包路径:org.mongodb.morphia.Datastore
类名称:Datastore
方法名:getByKey
[英]Find the given entity (by collectionName/id);
[中]查找给定实体(按collectionName/id);
代码示例来源:origin: lmco/streamflow
@Override
public T save(T entity) {
Key<T> key = datastore.save(entity);
return datastore.getByKey(persistentClass, key);
}
代码示例来源:origin: lmco/streamflow
@Override
public T update(T entity) {
Key<T> key = datastore.merge(entity);
return datastore.getByKey(persistentClass, key);
}
代码示例来源:origin: katharsis-project/katharsis-framework
public Task findOne(ObjectId id, QueryParams requestParams) {
return datastore.getByKey(Task.class, new Key<>(Task.class, id));
}
代码示例来源:origin: katharsis-project/katharsis-framework
public Project findOne(ObjectId id, QueryParams requestParams) {
return datastore.getByKey(Project.class, new Key<>(Project.class, id));
}
代码示例来源:origin: katharsis-project/katharsis-framework
public <S extends Project> S save(S entity) {
Key<Project> saveKey = (Key<Project>) datastore.save(entity);
return (S) datastore.getByKey(Project.class, saveKey);
}
代码示例来源:origin: katharsis-project/katharsis-framework
public <S extends Task> S save(S entity) {
Key<Task> saveKey = (Key<Task>) datastore.save(entity);
return (S) datastore.getByKey(Task.class, saveKey);
}
代码示例来源:origin: org.mongodb.morphia/morphia
protected abstract Object fetch();
代码示例来源:origin: org.mongodb.morphia/morphia
@Override
@SuppressWarnings("unchecked")
protected Object fetch() {
final Object entity = getDatastore().getByKey(referenceObjClass, key);
if (entity == null && !ignoreMissing) {
throw new LazyReferenceFetchingException(format("During the lifetime of the proxy, the Entity identified by '%s' "
+ "disappeared from the Datastore.", key));
}
return entity;
}
}
代码示例来源:origin: org.mongodb.morphia/morphia
@Override
@SuppressWarnings("unchecked")
protected synchronized Object fetch() {
final Collection<T> c = (Collection<T>) object;
c.clear();
final int numberOfEntitiesExpected = listOfKeys.size();
// does not retain order:
// List<T> retrievedEntities = p.get().getByKeys(referenceObjClass,
// (List) __getKeysAsList());
// so we do it the lousy way: FIXME
final List<T> retrievedEntities = new ArrayList<T>(listOfKeys.size());
for (final Key<?> k : listOfKeys) {
T entity = (T) getDatastore().getByKey(referenceObjClass, k);
if (entity != null) {
retrievedEntities.add(entity);
}
}
if (!ignoreMissing && (numberOfEntitiesExpected != retrievedEntities.size())) {
throw new LazyReferenceFetchingException(format("During the lifetime of a proxy of type '%s', some referenced Entities"
+ " of type '%s' have disappeared from the Datastore.",
c.getClass().getSimpleName(), referenceObjClass.getSimpleName()));
}
c.addAll(retrievedEntities);
return c;
}
内容来源于网络,如有侵权,请联系作者删除!