Example usage for org.springframework.data.mongodb.core.query Query Query

List of usage examples for org.springframework.data.mongodb.core.query Query Query

Introduction

In this page you can find the example usage for org.springframework.data.mongodb.core.query Query Query.

Prototype

public Query(CriteriaDefinition criteriaDefinition) 

Source Link

Document

Creates a new Query using the given CriteriaDefinition .

Usage

From source file:com.epam.ta.reportportal.database.dao.ProjectRepositoryCustomImpl.java

@Override
public List<Project> findUserProjects(String login) {
    return mongoTemplate.find(Query.query(userExists(login)), Project.class);
}

From source file:data.repository.pragma.mongo.StagingDBRepository.java

public boolean existDOByKey(String key, String value) {
    boolean result = stagingDBTemplate.findOne(Query.query(Criteria.where(key).is(value))).equals(null);
    return !result;
}

From source file:io.github.carlomicieli.springbooks.services.BookService.java

public List<Book> findByCommentAuthor(String commentAuthor) {
    return mongoTemplate.find(new Query(where("comments.author").is(commentAuthor)), Book.class);
}

From source file:uk.gov.nationalarchives.discovery.taxonomy.common.repository.mongo.impl.CategoryRepositoryImpl.java

@Override
public Category findByTtl(String ttl) {
    return categoriesMongoTemplate.findOne(new Query(Criteria.where(TTL_FIELD).is(ttl)), Category.class);
}

From source file:quanlyhocvu.api.mongodb.DAO.NewsDAO.java

/**
 * get all data pagination/*from   w w  w .  ja va  2  s  . c  o  m*/
 * @param limit
 * @param offset
 * @return 
 */
public List<NewsDTO> getAllNewsByPage(int limit, int offset) {
    Query query = Query.query(Criteria.where("id").exists(true));
    query.limit(limit);
    query.skip(offset);
    query.with(new Sort(Sort.Direction.DESC, "date"));
    return mongoOperation.find(query, NewsDTO.class);
}

From source file:org.ingini.mongodb.spring.example.read.TestFindWithRegex.java

@Test
public void shouldFindWithPatternCompile() {
    //GIVEN/*  w ww  .  j  a  va 2  s . co  m*/
    CollectionManager.cleanAndFill(mongoTemplate.getDb(), "weapons.json", WEAPONS);

    //WHEN
    List<Weapon> swordsOfSteel = mongoTemplate
            .find(Query.query(Criteria.where(Weapon.MATERIAL).regex(Pattern.compile("steel.*"))), Weapon.class);

    //THEN
    assertThat(swordsOfSteel).isNotEmpty();
    assertThat(swordsOfSteel).hasSize(3);
}

From source file:br.com.ezequieljuliano.argos.persistence.UserDAO.java

public User findByUserNameAndPassWord(String userName, String passWord) {
    Query query = new Query(Criteria.where("userName").is(userName).and("passWord").is(passWord));
    return getMongoOperations().findOne(query, User.class);
}

From source file:eu.trentorise.smartcampus.communicatorservice.storage.CommunicatorStorage.java

public <T extends BasicObject> void deleteObjectsPermanently(Class<T> cls, String user) throws DataException {
    mongoTemplate.remove(Query.query(Criteria.where("user").is(user).and("type").is(cls.getCanonicalName())),
            getObjectClass());//from w ww  .jav  a2  s .  c  o  m
}

From source file:strat.mining.multipool.stats.persistence.dao.donation.impl.TransactionDAOMongo.java

@Override
public Transaction getTransaction(String transactionId) {
    Query query = new Query(Criteria.where("transactionId").is(transactionId));
    return mongoOperation.findOne(query, Transaction.class);
}

From source file:quanlyhocvu.api.mongodb.DAO.DiemDAO.java

public DiemDTO getDiemByHocSinhChiTietMonHoc(HocSinhDTO hocSinh, ChiTietMonHocDTO chiTietMonHoc) {
    DiemDTO dto = new DiemDTO();
    Query query = Query.query(Criteria.where("hocSinh.&id").is(hocSinh.getid()))
            .addCriteria(Criteria.where("chiTietMonHoc.&id").is(chiTietMonHoc.getid()));
    dto = mongoOperation.findOne(query, DiemDTO.class);

    if (dto == null) {
        DiemDTO newDTO = new DiemDTO();
        newDTO.setChiTietMonHoc(chiTietMonHoc);
        newDTO.setHocSinh(hocSinh);//from   w ww. j a  v  a2 s.co m
        mongoOperation.insert(newDTO);
        dto = newDTO;
    }

    return dto;
}