本文整理了Java中org.springframework.data.mongodb.core.MongoTemplate.findById()
方法的一些代码示例,展示了MongoTemplate.findById()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MongoTemplate.findById()
方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.MongoTemplate
类名称:MongoTemplate
方法名:findById
暂无
代码示例来源:origin: spring-projects/spring-data-mongodb
@Nullable
@Override
public <T> T findById(Object id, Class<T> entityClass) {
return findById(id, entityClass, operations.determineCollectionName(entityClass));
}
代码示例来源:origin: kaaproject/kaa
public T findById(K key) {
LOG.debug("Find document of collection [{}] by id [{}]", getCollectionName(), key);
return mongoTemplate.findById(key, getDocumentClass());
}
代码示例来源:origin: lianggzone/springboot-action
public Author findAuthor(Long id) {
return this.mongoTemplate.findById(id, Author.class);
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
@Nullable
@Override
public <T> T findById(Object id, Class<T> entityClass) {
return findById(id, entityClass, operations.determineCollectionName(entityClass));
}
代码示例来源:origin: pl.edu.icm.synat/synat-core-services-impl
@Override
public FlowDefinitionElement findById(final String id) {
return mongoTemplate.findById(id, FlowDefinitionElement.class, collectionName);
}
代码示例来源:origin: 3zamn/kingMicro
@SuppressWarnings("unchecked")
@Override
public T findOne(ID id) {
return (T) mongoTemplate.findById(id, clz);
}
代码示例来源:origin: fernandospr/spring-jetty-example
@Override
public Student find(String id) {
return this.mongoTemplate.findById(id, Student.class);
}
代码示例来源:origin: pl.edu.icm.polindex/polindex-tools
@Override
public R getById(String recordId) {
logger.debug("executing mongo findById(" + recordId + ")");
R record = (R) mongoTemplate.findById(recordId, Record.class, collectionName);
return record;
}
代码示例来源:origin: at.researchstudio.sat/won-bot
private Object get(String collectionName, String key) {
MongoContextObject mco = template.findById(key, MongoContextObject.class, collectionName);
if (mco != null) {
return mco.getObject();
}
return null;
}
代码示例来源:origin: pl.edu.icm.synat/synat-business-services-impl
@Override
@RequiresServiceRole(roleName="READ")
public boolean validateCollectionExists(String collectionId) {
ElementCollection record = mongoTemplate.findById(collectionId, ElementCollection.class, mongoCollectionName);
return record != null;
}
代码示例来源:origin: pl.edu.icm.synat/synat-business-services-impl
private void checkElementCollection(String collectionId) {
ElementCollection record = mongoTemplate.findById(collectionId, ElementCollection.class, mongoCollectionName);
if (record == null ) {
throw new NotFoundException(collectionId);
}
}
protected void reportEvent(String collectionId, String contentId, CollectionDocumentType contentType, boolean wasDeleted) {
代码示例来源:origin: com.sangupta/jerry-services
@Override
public Configuration get(String key) {
if(AssertUtils.isEmpty(key)) {
throw new IllegalArgumentException("Configuration key cannot be null/empty");
}
return this.mongoTemplate.findById(key, Configuration.class);
}
代码示例来源:origin: at.researchstudio.sat/won-bot
@Override
public List<Object> loadFromListMap(final String collectionName, final String key) {
checkValidCollectionName(collectionName);
MongoContextObjectList mco = template.findById(key, MongoContextObjectList.class, collectionName);
return mco == null ? new LinkedList<>() : mco.getList();
}
代码示例来源:origin: pl.edu.icm.synat/synat-business-services-impl
@SuppressWarnings("unchecked")
@Override
public List<ResourceUserRole> findAllUserRoles(String resourceId) {
ResourceRoleElement element = mongoTemplate.findById(resourceId, ResourceRoleElement.class, collectionName);
if (element == null || element.getUserRoles() == null) {
return Collections.EMPTY_LIST;
}
return element.getUserRoles();
}
代码示例来源:origin: pl.edu.icm.synat/synat-business-services-impl
@Override
@RequiresServiceRole(roleName="READ")
public List<String> getCollectionContentIds(String collectionId) {
ElementCollection record = mongoTemplate.findById(collectionId, ElementCollection.class, mongoCollectionName);
List<String> result = new ArrayList<String>();
for (AttachedDocument doc : record.getAttachedDocuments()) {
result.add(doc.getDocumentId());
}
return result;
}
代码示例来源:origin: org.jspresso.framework/jspresso-mongo
@SuppressWarnings("unchecked")
@Override
public T doInTransaction(TransactionStatus status) {
return merge(getMongoTemplate().findById(id, clazz), mergeMode);
}
});
代码示例来源:origin: pl.edu.icm.synat/synat-business-services-impl
@Override
@RequiresServiceRole(roleName="READ")
public CollectionData fetchCollection(String collectionId) {
ElementCollection record = mongoTemplate.findById(collectionId, ElementCollection.class, mongoCollectionName);
if (record == null) {
return null;
}
// TODO Check credentials
return convertToCollectionData(record);
}
代码示例来源:origin: pl.edu.icm.synat/synat-business-services-impl
@Override
@RequiresServiceRole(roleName="READ")
public boolean checkIfContainsElement(String collectionId, String documentId) {
ElementCollection record = mongoTemplate.findById(collectionId, ElementCollection.class, mongoCollectionName);
for (AttachedDocument doc : record.getAttachedDocuments()) {
if (doc.getDocumentId().equals(documentId)) {
return true;
}
}
return false;
}
代码示例来源:origin: org.jspresso.framework/jspresso-mongo
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
merge(getMongoTemplate().findById(entity.getId(), getComponentContract(entity)),
EMergeMode.MERGE_CLEAN_EAGER);
}
});
代码示例来源:origin: pl.edu.icm.synat/synat-business-services-impl
@Override
public String getAttachedContentUserId(String collectionId, String documentId) {
ElementCollection record = mongoTemplate.findById(collectionId, ElementCollection.class, mongoCollectionName);
if (record == null) {
throw new CollectionServiceException(
"Getting document '{}' from collection '{}' failed. Collection doesn't exist.",
documentId, collectionId);
}
for (AttachedDocument doc : record.getAttachedDocuments()) {
if (doc.getDocumentId().equals(documentId)) {
return doc.getAttachedByUserId();
}
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!