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:org.starfishrespect.myconsumption.server.business.repositories.repositoriesimpl.UserRepositoryImpl.java

@Override
public boolean userExists(String name) {
    Query existingQuery = new Query(new Criteria("name").is(name));
    return mongoOperation.exists(existingQuery, User.class, COLLECTION_NAME);
}

From source file:com.pubkit.platform.persistence.impl.DeviceInfoDaoImpl.java

public DeviceInfo getDeviceInfoForRegistrationId(String applicationId, String registrationId) {
    Criteria criteria = Criteria.where("applicationId").is(applicationId).and("registrationId")
            .is(registrationId);/*  w  w  w .j a  va  2 s  . c o  m*/
    Query query = Query.query(criteria);

    return mongoTemplate.findOne(query, DeviceInfo.class);
}

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

public KhoiLopDTO getByName(String tenKhoiLop) {
    Query query = Query.query(Criteria.where("tenKhoiLop").is(tenKhoiLop));
    KhoiLopDTO obj = mongoOperation.findOne(query, KhoiLopDTO.class);
    return obj;//from   ww w. j  a v  a 2 s.  c om
}

From source file:org.oncoblocks.centromere.mongodb.test.EntrezGeneRepository.java

public List<EntrezGene> guessGene(String keyword) {
    Query query = new Query(Criteria.where("primaryGeneSymbol").is(keyword));
    Sort sort = new Sort(new Sort.Order(Sort.Direction.ASC, "entrezGeneId"));
    List<EntrezGene> genes = getMongoOperations().find(query.with(sort), getModel());
    if (genes != null && genes.size() > 0)
        return genes;
    query = new Query(Criteria.where("aliases").is(keyword));
    genes = getMongoOperations().find(query.with(sort), getModel());
    if (genes != null && genes.size() > 0)
        return genes;
    return null;//w w w  .  ja v a2 s .c  om
}

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

public boolean existDOByID(String id) {
    boolean result = stagingDBTemplate.findOne(Query.query(Criteria.where("_id").is(id))).equals(null);
    return !result;
}

From source file:no.nlf.dal.LicenseController.java

public License update(License license) {
    MongoLicense mongoLicense = new MongoLicense(license);
    Query searchQuery = new Query(Criteria.where("id").is(mongoLicense.getId()));

    Update updateLicense = new Update();

    updateLicense.set("melwinId", mongoLicense.getMelwinId());
    updateLicense.set("licenseName", mongoLicense.getLicenseName());
    updateLicense.set("active", mongoLicense.isActive());

    mongoLicense = appContext.mongoOperation().findAndModify(searchQuery, updateLicense,
            new FindAndModifyOptions().returnNew(true), MongoLicense.class);

    if (mongoLicense == null) {
        return new License();
    }/*from ww w  .  j  av a  2 s .  c  o m*/

    return mongoLicense.toLicense();
}

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

public User findByIdentifierKey(String identifierKey) {
    Query query = new Query(Criteria.where("identifierKey").is(identifierKey));
    return getMongoOperations().findOne(query, User.class);
}

From source file:com.ewcms.common.query.mongo.EasyQueryImpl.java

@Override
public Result<T> find() {
    List<T> list = operations.find(Query.query(criteria), entityClass);
    return new ResultImpl<T>(list);
}

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

public <T extends BasicObject> void deleteObjectPermanently(T object) throws DataException {
    mongoTemplate.remove(Query.query(Criteria.where("id").is(object.getId())), getObjectClass());
}

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

@Test
public void shouldFindOneEntryBasedOnOIDOperator() {
    //GIVEN//ww  w  .j  a  va  2  s  .co  m
    CollectionManager.cleanAndFill(mongoTemplate.getDb(), "characters.json", HumanCharacter.COLLECTION_NAME);

    //WHEN
    Hero hero = mongoTemplate.findOne(
            Query.query(Criteria.where("_id").is(new ObjectId("52516b563004ba6b745e864f"))), Hero.class);

    //THEN
    assertThat(hero).isNotNull();

}