org.springframework.data.mongodb.core.MongoTemplate.findOne()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(182)

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

MongoTemplate.findOne介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-data-mongodb

@Nullable
@Override
public <T> T findOne(Query query, Class<T> entityClass) {
  return findOne(query, entityClass, operations.determineCollectionName(entityClass));
}

代码示例来源:origin: kaaproject/kaa

protected T findOne(Query query) {
 return mongoTemplate.findOne(query, getDocumentClass());
}

代码示例来源:origin: ityouknow/spring-boot-examples

/**
 * 根据用户名查询对象
 * @param userName
 * @return
 */
@Override
public UserEntity findUserByUserName(String userName) {
  Query query=new Query(Criteria.where("userName").is(userName));
  UserEntity user =  mongoTemplate.findOne(query , UserEntity.class);
  return user;
}

代码示例来源:origin: roncoo/spring-boot-demo

public RoncooUser selectById(int id) {
    Criteria criteria = Criteria.where("id").in(id);
    Query query = new Query(criteria);
    return mongoTemplate.findOne(query, RoncooUser.class);
  }
}

代码示例来源:origin: roncoo/spring-boot-demo

public RoncooUser selectById(int id) {
    Criteria criteria = Criteria.where("id").in(id);
    Query query = new Query(criteria);
    return mongoTemplate.findOne(query, RoncooUser.class);
  }
}

代码示例来源:origin: roncoo/spring-boot-demo

public RoncooUser selectById(int id) {
    Criteria criteria = Criteria.where("id").in(id);
    Query query = new Query(criteria);
    return mongoTemplate.findOne(query, RoncooUser.class);
  }
}

代码示例来源:origin: roncoo/spring-boot-demo

public RoncooUser selectById(int id) {
    Criteria criteria = Criteria.where("id").in(id);
    Query query = new Query(criteria);
    return mongoTemplate.findOne(query, RoncooUser.class);
  }
}

代码示例来源:origin: roncoo/spring-boot-demo

public RoncooUser selectById(int id) {
    Criteria criteria = Criteria.where("id").in(id);
    Query query = new Query(criteria);
    return mongoTemplate.findOne(query, RoncooUser.class);
  }
}

代码示例来源:origin: roncoo/spring-boot-demo

public RoncooUser selectById(int id) {
    Criteria criteria = Criteria.where("id").in(id);
    Query query = new Query(criteria);
    return mongoTemplate.findOne(query, RoncooUser.class);
  }
}

代码示例来源:origin: roncoo/spring-boot-demo

public RoncooUser selectById(int id) {
    Criteria criteria = Criteria.where("id").in(id);
    Query query = new Query(criteria);
    return mongoTemplate.findOne(query, RoncooUser.class);
  }
}

代码示例来源:origin: roncoo/spring-boot-demo

public RoncooUser selectById(int id) {
    Criteria criteria = Criteria.where("id").in(id);
    Query query = new Query(criteria);
    return mongoTemplate.findOne(query, RoncooUser.class);
  }
}

代码示例来源:origin: roncoo/spring-boot-demo

public RoncooUser selectById(int id) {
    Criteria criteria = Criteria.where("id").in(id);
    Query query = new Query(criteria);
    return mongoTemplate.findOne(query, RoncooUser.class);
  }
}

代码示例来源:origin: yu199195/hmily

@Override
public HmilyTransaction findById(final String id) {
  Query query = new Query();
  query.addCriteria(new Criteria("transId").is(id));
  MongoAdapter cache = template.findOne(query, MongoAdapter.class, collectionName);
  return buildByCache(Objects.requireNonNull(cache));
}

代码示例来源:origin: yu199195/Raincat

@Override
public TransactionRecover findById(final String id) {
  Query query = new Query();
  query.addCriteria(new Criteria("transId").is(id));
  MongoAdapter cache = template.findOne(query, MongoAdapter.class, collectionName);
  return buildByCache(cache);
}

代码示例来源:origin: yu199195/myth

@Override
public MythTransaction findByTransId(final String transId) {
  Query query = new Query();
  query.addCriteria(new Criteria("transId").is(transId));
  MongoAdapter cache = template.findOne(query, MongoAdapter.class, collectionName);
  return buildByCache(cache);
}

代码示例来源:origin: kaaproject/kaa

@Override
public EndpointProfileBodyDto findBodyByKeyHash(byte[] endpointKeyHash) {
 LOG.debug("Find endpoint profile body by endpoint key hash [{}] ", endpointKeyHash);
 EndpointProfileBodyDto endpointProfileBodyDto = null;
 Query query = Query.query(where(EP_ENDPOINT_KEY_HASH).is(endpointKeyHash));
 query.fields()
   .include(DaoConstants.PROFILE)
   .include(EP_SERVER_PROFILE_PROPERTY)
   .include(EP_APPLICATION_ID)
   .include(EP_PROFILE_VERSION)
   .include(EP_SERVER_PROFILE_VERSION_PROPERTY)
   .include(EP_USE_RAW_SCHEMA);
 EndpointProfileDto pf = mongoTemplate.findOne(query, getDocumentClass()).toDto();
 if (pf != null) {
  endpointProfileBodyDto = new EndpointProfileBodyDto(
    endpointKeyHash,
    pf.getClientProfileBody(),
    pf.getServerProfileBody(),
    pf.getClientProfileVersion(),
    pf.getServerProfileVersion(),
    pf.getApplicationId());
 }
 LOG.debug("[{}] Found client-side endpoint profile body {} with client-side endpoint "
     + "profile version {} and server-side endpoint profile body {} "
     + "with server-side endpoint profile version {} and application id {}",
   endpointKeyHash, pf.getClientProfileBody(), pf.getServerProfileBody(),
   pf.getClientProfileVersion(), pf.getServerProfileVersion(), pf.getApplicationId());
 return endpointProfileBodyDto;
}

代码示例来源:origin: org.springframework.data/spring-data-mongodb

@Nullable
@Override
public <T> T findOne(Query query, Class<T> entityClass) {
  return findOne(query, entityClass, operations.determineCollectionName(entityClass));
}

代码示例来源:origin: spring-projects/spring-integration

@Override
public Message<?> getOneMessageFromGroup(Object groupId) {
  Assert.notNull(groupId, "'groupId' must not be null");
  Query query = whereGroupIdOrder(groupId);
  MessageWrapper messageWrapper = this.template.findOne(query, MessageWrapper.class, this.collectionName);
  if (messageWrapper != null) {
    return messageWrapper.getMessage();
  }
  else {
    return null;
  }
}

代码示例来源:origin: spring-projects/spring-integration

@Override
public Message<?> getOneMessageFromGroup(Object groupId) {
  Assert.notNull(groupId, "'groupId' must not be null");
  Query query = groupOrderQuery(groupId);
  MessageDocument messageDocument = this.mongoTemplate.findOne(query, MessageDocument.class, this.collectionName);
  if (messageDocument != null) {
    return messageDocument.getMessage();
  }
  else {
    return null;
  }
}

代码示例来源:origin: spring-projects/spring-integration

public Message<?> getMessage(UUID id) {
  Assert.notNull(id, "'id' must not be null");
  Query query = Query.query(Criteria.where(MessageDocumentFields.MESSAGE_ID).is(id));
  MessageDocument document = this.mongoTemplate.findOne(query, MessageDocument.class, this.collectionName);
  return document != null ? document.getMessage() : null;
}

相关文章