List of usage examples for com.mongodb DBCursor close
@Override public void close()
From source file:cn.vlabs.clb.server.storage.mongo.extend.MyGridFS.java
License:Apache License
public List<MyGridFSDBFile> find(DBObject query, DBObject sort) { List<MyGridFSDBFile> files = new ArrayList<MyGridFSDBFile>(); DBCursor c = null; try {/*ww w . j a va 2 s . c om*/ c = _filesCollection.find(query); if (sort != null) { c.sort(sort); } while (c.hasNext()) { files.add(_fix(c.next())); } } finally { if (c != null) { c.close(); } } return files; }
From source file:co.edu.uniandes.cloud.simuladorcredito.persistencia.SecuenciaDAO.java
public Secuencia leer(String llave) { BasicDBObject query = new BasicDBObject("tabla", llave); DBCursor cursor = col.find(query); try {//from www .j a v a 2s . c om if (cursor.hasNext()) { Secuencia s = new Secuencia(); DBObject obj = cursor.next(); s.setTabla((String) obj.get("tabla")); s.setSecuencia((Long) obj.get("secuencia")); return s; } else { return null; } } finally { cursor.close(); } }
From source file:co.edu.uniandes.cloud.simuladorcredito.persistencia.SuperDAO.java
protected DBObject leerBD(String campo, Object valor) { BasicDBObject query = new BasicDBObject(campo, valor); DBCursor cursor = col.find(query); try {//from w ww . j ava 2 s . com if (cursor.hasNext()) { return cursor.next(); } else { return null; } } finally { cursor.close(); } }
From source file:co.edu.uniandes.cloud.simuladorcredito.persistencia.SuperDAO.java
protected List<DBObject> leerVariosBD(String campo, Object valor) { List<DBObject> lista = new ArrayList(); BasicDBObject query = new BasicDBObject(campo, valor); DBCursor cursor = col.find(query); try {/* w w w. ja v a2s . c om*/ while (cursor.hasNext()) { lista.add(cursor.next()); } } finally { cursor.close(); } return lista; }
From source file:co.edu.uniandes.csw.Arquidalgos.usuario.persistence._UsuarioPersistence.java
License:MIT License
@SuppressWarnings("unchecked") public List<UsuarioDTO> getUsuarios() { // Query q = entityManager.createQuery("select u from UsuarioEntity u"); // return UsuarioConverter.entity2PersistenceDTOList(q.getResultList()); List listaUsuarios = new ArrayList(); DBCollection coll = db.getCollection("UsuarioDTO"); BasicDBObject query = new BasicDBObject(); DBCursor cursor = coll.find(query); while (cursor.hasNext()) { DBObject dBObject = cursor.next(); UsuarioDTO user = new UsuarioDTO(); user.setName((String) dBObject.get("name")); user.setContrasena((String) dBObject.get("contrasena")); user.setEmail((String) dBObject.get("email")); user.setFacebookId((String) dBObject.get("facebookId")); //TODO imprimir usuarios listaUsuarios.add(user);/*from w w w .j ava 2s .c om*/ } cursor.close(); return listaUsuarios; }
From source file:com.affairs.dao.zaffar.CurrentAffairsDAO.java
License:Apache License
public DBObject findByObjectId(String ObjectId) { DBObject sayDoProjectObj = null;/*w ww. ja v a 2 s. c o m*/ DBCursor sayDoProjectCursor = null; try { sayDoProjectCursor = this.saydoCollection.find(new BasicDBObject("_id", ObjectId)); while (sayDoProjectCursor.hasNext()) { sayDoProjectObj = sayDoProjectCursor.next(); } } catch (Exception exp) { System.out.println(exp.getMessage()); } finally { sayDoProjectCursor.close(); } return sayDoProjectObj; }
From source file:com.affairs.dao.zaffar.CurrentAffairsDAO.java
License:Apache License
public List findAllObjectByCondition(BasicDBObject whereConditionObj) { List<DBObject> projectList = new ArrayList<DBObject>(); DBCursor projectListCursor = this.saydoCollection.find(whereConditionObj).limit(SAYDO_UI_DISPLAY_LIMIT); DBObject projectCursor = new BasicDBObject(); try {//from w w w . ja va 2s . c om while (projectListCursor.hasNext()) { projectCursor = projectListCursor.next(); projectList.add(projectCursor); } } catch (Exception exp) { System.out.println(exp.getMessage()); } finally { projectListCursor.close(); } return projectList; }
From source file:com.affairs.dao.zaffar.EntityDAO.java
License:Apache License
public List<DBObject> findEntitiesByType(ArrayList entityTypes) { List<DBObject> entityList = new ArrayList<DBObject>(); DBObject whereCondition = new BasicDBObject().append("isCurrent", true).append("delInd", false) .append("type", new BasicDBObject("$in", entityTypes)); DBObject sortCondition = new BasicDBObject().append("type", 1).append("mnm", 1); DBCursor entityListCursor = this.entityCollection.find(whereCondition).sort(sortCondition); DBObject entityCursor = new BasicDBObject(); try {/*from w w w . j ava 2s . c o m*/ while (entityListCursor.hasNext()) { entityCursor = entityListCursor.next(); entityList.add(entityCursor); } } catch (Exception exp) { System.out.println(exp.getMessage()); } finally { entityListCursor.close(); } return entityList; }
From source file:com.affairs.dao.zaffar.EntityDAO.java
License:Apache License
public DBObject findByObjectId(String ObjectId) { DBObject entityObj = null;//from ww w . ja v a2 s . c om DBCursor entityCursor = null; try { entityCursor = this.entityCollection.find(new BasicDBObject("_id", ObjectId)); while (entityCursor.hasNext()) { entityObj = entityCursor.next(); } } catch (Exception exp) { System.out.println(exp.getMessage()); } finally { entityCursor.close(); } return entityObj; }
From source file:com.affairs.dao.zaffar.EntityDAO.java
License:Apache License
public List findAllObjectByCondition(BasicDBObject whereConditionObj) { List<DBObject> entityList = new ArrayList<DBObject>(); DBCursor entityListCursor = this.entityCollection.find(whereConditionObj); DBObject entityCursor = new BasicDBObject(); try {/*w w w . j a v a2s . co m*/ while (entityListCursor.hasNext()) { entityCursor = entityListCursor.next(); entityList.add(entityCursor); } } catch (Exception exp) { System.out.println(exp.getMessage()); } finally { entityListCursor.close(); } return entityList; }