本文整理汇总了Java中org.mongodb.morphia.dao.BasicDAO类的典型用法代码示例。如果您正苦于以下问题:Java BasicDAO类的具体用法?Java BasicDAO怎么用?Java BasicDAO使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BasicDAO类属于org.mongodb.morphia.dao包,在下文中一共展示了BasicDAO类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateEntityWithBasicDBList
import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testCreateEntityWithBasicDBList() throws Exception {
BasicDAO<TestEntity, ObjectId> dao;
dao = new BasicDAO<TestEntity, ObjectId>(TestEntity.class, getDs());
TestEntity entity = new TestEntity();
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
data.add(new BasicDBObject("type", "text")
.append("data", new BasicDBObject("text", "sometext")));
entity.setData(data);
dao.save(entity);
final TestEntity fetched = dao.get(entity.getId());
Assert.assertEquals(entity, fetched);
}
示例2: testMapping
import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
@Test
public void testMapping() {
final BasicDAO<User, ObjectId> messageDAO = new BasicDAO<User, ObjectId>(User.class, getDs());
Assert.assertNotNull(messageDAO);
Mapper mapper = new Mapper();
User user = new User();
user.id = 1;
user.userObject = "just a String";
DBObject dbObject = mapper.toDBObject(user);
Object object = mapper.fromDBObject(getDs(), User.class, dbObject, new DefaultEntityCache());
Assert.assertEquals(user.userObject, ((User) object).userObject);
user.userObject = 33;
dbObject = mapper.toDBObject(user);
object = mapper.fromDBObject(getDs(), User.class, dbObject, new DefaultEntityCache());
Assert.assertEquals(user.userObject, ((User) object).userObject);
user.userObject = 33.3;
dbObject = mapper.toDBObject(user);
object = mapper.fromDBObject(getDs(), User.class, dbObject, new DefaultEntityCache());
Assert.assertEquals(user.userObject, ((User) object).userObject);
}
示例3: MongoServiceDao
import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
public MongoServiceDao(Datastore datastore, Class<V> entityClazz, StatsReporter statsReporter) {
this.morphiaDao = new BasicDAO<>(entityClazz, datastore);
this.entityClazz = entityClazz;
this.entityInfo = EntityInfo.get(entityClazz);
this.entityIndexInfo = new EntityIndexInfo<>(entityClazz, morphiaDao.getCollection().getIndexInfo());
this.collectionName = morphiaDao.getCollection().getName();
this.statsReporter = statsReporter;
}
示例4: FeedsCreator
import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
public FeedsCreator(Configuration config) throws Exception {
morphia.map(Feed.class);
this.host = config.getParameter(HOST);
this.db = config.getParameter(DB);
this.username = config.getParameter(USERNAME);
this.password = config.getParameter(PASSWORD);
MongoClient mongoClient;
if(username != null && !username.equals("") && password != null && !password.equals("")) {
MongoClientOptions options = MongoClientOptions.builder().build();
ServerAddress srvAdr = new ServerAddress(host != null ? host : "localhost" , 27017);
MongoCredential credential = MongoCredential.createScramSha1Credential(username, "admin", password.toCharArray());
mongoClient = new MongoClient(srvAdr, Arrays.asList(credential), options);
}
else {
mongoClient = new MongoClient(host);
}
feedsDao = new BasicDAO<>(Feed.class, mongoClient, morphia, db);
// ensure capped collections
feedsDao.getDatastore().ensureCaps();
}
示例5: MorphiaDAO
import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
public MorphiaDAO (String hostname, String dbname, Class<K> clazz) throws Exception {
Morphia morphia = new Morphia();
MongoClient mongoClient = new MongoClient(hostname);
ds = morphia.createDatastore(mongoClient, dbname);
dao = new BasicDAO<K, String>(clazz, mongoClient, morphia, dbname);
this.clazz = clazz;
}
示例6: DAOManager
import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
public DAOManager(String dbName) {
imageDAO = new MediaDAO<Image>(Image.class, dbName);
videoDAO = new MediaDAO<Video>(Video.class, dbName);
textDAO = new ObjectDAO<Text>(Text.class, dbName);
postDAO = new ObjectDAO<Post>(Post.class, dbName);
pageDAO = new ObjectDAO<Webpage>(Webpage.class, dbName);
userDAO = new BasicDAO<UserAccount, String>(UserAccount.class, MorphiaManager.getMongoClient(), MorphiaManager.getMorphia(), MorphiaManager.getDB(dbName).getName());
domainDAO = new BasicDAO<WebDomain, String>(WebDomain.class, MorphiaManager.getMongoClient(), MorphiaManager.getMorphia(), MorphiaManager.getDB(dbName).getName());
clusterDAO = new BasicDAO<>(Cluster.class, MorphiaManager.getMongoClient(), MorphiaManager.getMorphia(), MorphiaManager.getDB(dbName).getName());
crawlsDAO = new BasicDAO<>(CrawlJob.class, MorphiaManager.getMongoClient(), MorphiaManager.getMorphia(), MorphiaManager.getCrawlsDB().getName());
associationDAO = new AssociationDAO(dbName);
//associationDAO = new BasicDAO<Association, ObjectId>(Association.class, MorphiaManager.getMongoClient(), MorphiaManager.getMorphia(), MorphiaManager.getDB(dbName).getName());
}
示例7: MongoStatisticsDao
import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
@Inject
public MongoStatisticsDao(MongoDB mongoDB, StatisticsUpdateScheduler scheduler) {
this.mongoDB = mongoDB;
this.scheduler = scheduler;
this.dao = new BasicDAO<MongoStatistics, MongoStatisticKey>(
MongoStatistics.class, mongoDB.getDatastore());
}
示例8: MongoUserStatisticDao
import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
@Inject
public MongoUserStatisticDao(MongoDB mongoDB, DataService dataService, UserStatisticUpdateScheduler scheduler) {
this.mongoDB = mongoDB;
this.dao = new BasicDAO<>(
MongoUserStatistic.class, mongoDB.getDatastore());
this.scheduler = scheduler;
this.dataService = dataService;
}
示例9: testFetchKey
import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
@Test
public void testFetchKey() {
getDs().save(new ConfigEntry(new ConfigKey("env", "key", "subenv")));
BasicDAO<ConfigEntry, ConfigKey> innerDAO = new BasicDAO<ConfigEntry, ConfigKey>(ConfigEntry.class, getDs());
ConfigEntry entry = innerDAO.find().get();
entry.setValue("something");
innerDAO.save(entry);
}
示例10: MorphiaRepository
import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
public MorphiaRepository(final BasicDAO<T, I> dao) {
this.dao = dao;
}
示例11: Transaction
import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
public Transaction(BasicDAO<T,K> basicDao) {
super();
this.basicDao = basicDao;
reverted = false;
}
示例12: getBasicDao
import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
public BasicDAO<T,K> getBasicDao() {
return basicDao;
}
示例13: setBasicDao
import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
public void setBasicDao(BasicDAO<T,K> basicDao) {
this.basicDao = basicDao;
}
示例14: AddBatchTransaction
import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
public AddBatchTransaction(BasicDAO<T, K> basicDAO, List<T> bbList) {
super(basicDAO);
this.bbList = bbList;
}
示例15: DeleteTransaction
import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
public DeleteTransaction(BasicDAO<T, K> basicDao, T t) {
super(basicDao);
this.bb = t;
}