Example usage for org.springframework.data.mongodb.core.query Criteria where

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

Introduction

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

Prototype

public static Criteria where(String key) 

Source Link

Document

Static factory method to create a Criteria using the provided key

Usage

From source file:com.springapp.mvc.dao.impl.WarehouseDaoImpl.java

@Override
public Warehouse getById(int code) {

    Query select = new Query(Criteria.where("_code").is(code));

    return mongoOperations.findOne(select, Warehouse.class, WAREHOUSE_COLLECIONS);
}

From source file:com.handu.open.dubbo.monitor.support.QueryConstructor.java

public <T> QueryConstructor addBetweenAttribute(String name, T before, T after) {
    if (before == null) {
        return this;
    }//from   ww  w .  ja  v a2  s. c  o  m
    if (after == null) {
        return this;
    }
    query.addCriteria(Criteria.where(name).gte(before).lte(after));
    return this;
}

From source file:com.real.apps.shuttle.repository.VehicleRepositoryTest.java

@Test
public void shouldSaveVehicleIntoMongo() {
    String make = "Test Vehicle Make To Be Inserted";
    Vehicle vehicle = new Vehicle();
    vehicle.setMake(make);/*from  w  w  w.j  a v a  2 s  . c om*/
    Vehicle saved = repository.save(vehicle);
    assertThat(saved.getId(), notNullValue());
    Query query = new Query(Criteria.where("make").is(make));
    Vehicle found = operations.findOne(query, Vehicle.class);
    assertThat(found.getMake(), notNullValue());
    operations.remove(query, Vehicle.class);
}

From source file:org.openinfinity.tagcloud.domain.repository.ProfileRepositoryMongoDBImpl.java

@Override
public Profile loadByFacebookId(String facebookId) {
    Query query = new Query(Criteria.where("facebookId").is(facebookId));
    List<Profile> profiles = mongoTemplate.find(query, Profile.class);
    if (profiles.size() == 0)
        return null;
    else//www.  j a v a 2 s . c  om
        return profiles.get(0);
}

From source file:jp.co.ctc_g.rack.connector.keypair.WooreaKeypairRepository.java

/**
 * {@inheritDoc}//from   w  w w.ja va  2s . c om
 */
@Override
public WooreaKeypair findBy(String groupId) {

    return operations.findOne(new Query().addCriteria(Criteria.where("groupId").is(groupId)),
            WooreaKeypair.class);
}

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

@Override
public int deleteByCategory(String categoryName) {
    Query query = new Query(Criteria.where("CATEGORY").is(categoryName));
    WriteResult writeResult = categoriesMongoTemplate.remove(query, TrainingDocument.class);
    return writeResult.getN();
}

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

public List<Marker> findByParent(Marker parent) {
    Query query = new Query(Criteria.where("parent").is(parent));
    return getMongoOperations().find(query, Marker.class);
}

From source file:com.ciphertool.zodiacengine.dao.CipherDao.java

@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW)
public Cipher findByCipherName(String name) {
    Query selectByNameQuery = new Query(Criteria.where("name").is(name));

    Cipher cipher = mongoOperations.findOne(selectByNameQuery, Cipher.class);

    return cipher;
}

From source file:de.iew.raspimotion.persistence.mongodb.MongoDbFileDaoImpl.java

public FileDescriptor getFileLastCreated(String filename) throws Exception {
    Query query = new Query(Criteria.where("filename").is(filename))
            .with(new Sort(new Sort.Order(Sort.Direction.DESC, "uploadDate")));

    return this.mongoTemplate.findOne(query, MongoDbFile.class, "fs.files");
}

From source file:com.jelastic.campitos.ServicioUsuario.java

public void obtenerUno(Usuario usuario) {
    mongoTemplate.findOne(new Query(Criteria.where("nombre").is(usuario.getNombre())), Usuario.class);

}