当前位置: 首页>>代码示例>>Java>>正文


Java BasicDAO类代码示例

本文整理汇总了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);
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:19,代码来源:CollectionOfValuesTest.java

示例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);
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:26,代码来源:TestMapping.java

示例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;
}
 
开发者ID:researchgate,项目名称:restler,代码行数:9,代码来源:MongoServiceDao.java

示例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();
}
 
开发者ID:MKLab-ITI,项目名称:simmo-stream-manager,代码行数:28,代码来源:FeedsCreator.java

示例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;
}
 
开发者ID:MKLab-ITI,项目名称:mgraph-summarization,代码行数:9,代码来源:MorphiaDAO.java

示例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());
}
 
开发者ID:MKLab-ITI,项目名称:simmo,代码行数:14,代码来源:DAOManager.java

示例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());
}
 
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:8,代码来源:MongoStatisticsDao.java

示例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;
}
 
开发者ID:enviroCar,项目名称:enviroCar-server,代码行数:9,代码来源:MongoUserStatisticDao.java

示例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);
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:9,代码来源:CompoundIdTest.java

示例10: MorphiaRepository

import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
public MorphiaRepository(final BasicDAO<T, I> dao) {
    this.dao = dao;
}
 
开发者ID:pgentile,项目名称:zucchini-ui,代码行数:4,代码来源:MorphiaRepository.java

示例11: Transaction

import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
public Transaction(BasicDAO<T,K> basicDao) {
	super();
	this.basicDao = basicDao;
	reverted = false;
}
 
开发者ID:liyang-bsy,项目名称:LYLab,代码行数:6,代码来源:Transaction.java

示例12: getBasicDao

import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
public BasicDAO<T,K> getBasicDao() {
	return basicDao;
}
 
开发者ID:liyang-bsy,项目名称:LYLab,代码行数:4,代码来源:Transaction.java

示例13: setBasicDao

import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
public void setBasicDao(BasicDAO<T,K> basicDao) {
	this.basicDao = basicDao;
}
 
开发者ID:liyang-bsy,项目名称:LYLab,代码行数:4,代码来源:Transaction.java

示例14: AddBatchTransaction

import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
public AddBatchTransaction(BasicDAO<T, K> basicDAO, List<T> bbList) {
	super(basicDAO);
	this.bbList = bbList;
}
 
开发者ID:liyang-bsy,项目名称:LYLab,代码行数:5,代码来源:AddBatchTransaction.java

示例15: DeleteTransaction

import org.mongodb.morphia.dao.BasicDAO; //导入依赖的package包/类
public DeleteTransaction(BasicDAO<T, K> basicDao, T t) {
	super(basicDao);
	this.bb = t;
}
 
开发者ID:liyang-bsy,项目名称:LYLab,代码行数:5,代码来源:DeleteTransaction.java


注:本文中的org.mongodb.morphia.dao.BasicDAO类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。