List of usage examples for com.mongodb BasicDBObjectBuilder start
public static BasicDBObjectBuilder start()
From source file:com.packages.mongodb.dao.automobilsdao.java
public void updateautomobile(automobile p) { DBObject query = BasicDBObjectBuilder.start().append("_id", new ObjectId(p.getid())).get(); this.col.update(query, automobileconverter.toDBObject(p)); }
From source file:com.packages.mongodb.dao.automobilsdao.java
public void deleteautomobile(automobile p) { DBObject query = BasicDBObjectBuilder.start().append("_id", new ObjectId(p.getid())).get(); this.col.remove(query); }
From source file:com.packages.mongodb.dao.automobilsdao.java
public automobile readautomobile(automobile p) { DBObject query = BasicDBObjectBuilder.start().append("_id", new ObjectId(p.getid())).get(); DBObject data = this.col.findOne(query); return automobileconverter.toautomobile(data); }
From source file:com.packages.mongodb.dao.hoteldao.java
public void updatehotel(hotels p) { DBObject query = BasicDBObjectBuilder.start().append("_id", new ObjectId(p.getid())).get(); this.col.update(query, hotelconverter.toDBObject(p)); }
From source file:com.packages.mongodb.dao.hoteldao.java
public void deletehotel(hotels p) { DBObject query = BasicDBObjectBuilder.start().append("_id", new ObjectId(p.getid())).get(); this.col.remove(query); }
From source file:com.packages.mongodb.dao.hoteldao.java
public hotels readhotel(hotels p) { DBObject query = BasicDBObjectBuilder.start().append("_id", new ObjectId(p.getid())).get(); DBObject data = this.col.findOne(query); return hotelconverter.tohotel(data); }
From source file:com.packages.mongodb.dao.individualdao.java
public void updateindividual(individual p) { DBObject query = BasicDBObjectBuilder.start().append("_id", new ObjectId(p.getid())).get(); this.col.update(query, individualconverter.toDBObject(p)); }
From source file:com.packages.mongodb.dao.individualdao.java
public void deleteindividual(individual p) { DBObject query = BasicDBObjectBuilder.start().append("_id", new ObjectId(p.getid())).get(); this.col.remove(query); }
From source file:com.packages.mongodb.dao.individualdao.java
public individual readindividual(individual p) { DBObject query = BasicDBObjectBuilder.start().append("_id", new ObjectId(p.getid())).get(); DBObject data = this.col.findOne(query); return individualconverter.toindividual(data); }
From source file:com.stratio.tests.ATExampleMongoDB.java
License:Apache License
@BeforeClass public void setUp() throws UnknownHostException { MongoClient mongoClient = new MongoClient(mongoHost, mongoPort); mongoClient.dropDatabase(dataBase);/*from w w w .ja v a 2s . c om*/ DB db = mongoClient.getDB(dataBase); DBCollection tabletest = db.getCollection("tabletest"); // DBCollection tabletest = db.createCollection("tabletest"); SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy"); format.setTimeZone(TimeZone.getTimeZone("CET")); for (int i = 0; i < 10; i++) { Date parsedDate = null; String fecha = i + "/" + i + "/200" + i; try { parsedDate = format.parse(fecha); } catch (ParseException e) { e.printStackTrace(); } System.out.println(new java.sql.Date(parsedDate.getTime()).toString()); BasicDBObjectBuilder documentBuilder = BasicDBObjectBuilder.start().add("ident", i) .add("name", "name_" + i).add("money", 10.2 + i).add("new", true) .add("date", new java.sql.Date(parsedDate.getTime())); tabletest.insert(documentBuilder.get()); } // DBObject aux = tabletest.findOne(); // java.sql.Date aux1 = (java.sql.Date)aux.get("date"); mongoClient.close(); String connector = "Mongo"; //Preparamos las cositas para compartir ThreadProperty.set("Host", "127.0.0.1"); ThreadProperty.set("Connector", connector); }