• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DatabaseAdapter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.orm.androrm.DatabaseAdapter的典型用法代码示例。如果您正苦于以下问题:Java DatabaseAdapter类的具体用法?Java DatabaseAdapter怎么用?Java DatabaseAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DatabaseAdapter类属于com.orm.androrm包,在下文中一共展示了DatabaseAdapter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: syncDB

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
/**
 * Tell AndOrm about the Models that will be used to read and write to the database.
 */
public void syncDB() {
    List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
    models.add(GameSession.class);
    models.add(MarketRequest.class);
    models.add(RequestItem.class);
    models.add(InventoryItem.class);
    models.add(DefaultTile.class);
    models.add(LetterTile.class);
    models.add(WordTile.class);
    models.add(LetterBuilder.class);
    models.add(WordTileBuilder.class);
    models.add(WordBuilder.class);
    models.add(WorkshopBuilder.class);
    models.add(GameTile.class);
    models.add(GameTileBuilder.class);
    models.add(GameTileTimer.class);
    models.add(DecorationTile.class);

    DatabaseAdapter.setDatabaseName("game_db");
    DatabaseAdapter adapter = DatabaseAdapter.getInstance(PhoeniciaContext.context);
    adapter.setModels(models);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:26,代码来源:GameActivity.java


示例2: setUp

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    PhoeniciaContext.context = getContext();
    assertNotNull("Null context", PhoeniciaContext.context);

    List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
    models.add(GameSession.class);

    DatabaseAdapter.setDatabaseName("game_db");
    DatabaseAdapter adapter = DatabaseAdapter.getInstance(PhoeniciaContext.context);
    adapter.setModels(models);

    this.session = new GameSession();
    session.session_name.set("test session");
    session.locale_pack.set("test-locale");
    session.current_level.set("test-level");
    session.save(PhoeniciaContext.context);

    assertNotNull(session.getId());
    Bank.init(session);

}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:24,代码来源:BankTest.java


示例3: setUp

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
public void setUp() throws Exception {
    super.setUp();
    PhoeniciaContext.context = getContext();
    assertNotNull("Null context", PhoeniciaContext.context);

    List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
    models.add(GameSession.class);
    models.add(InventoryItem.class);

    DatabaseAdapter.setDatabaseName("game_db");
    DatabaseAdapter adapter = DatabaseAdapter.getInstance(PhoeniciaContext.context);
    adapter.setModels(models);


    GameSession session = new GameSession();
    session.session_name.set("test session");
    session.locale_pack.set("test-locale");
    session.current_level.set("test-level");
    session.save(PhoeniciaContext.context);

    assertNotNull(session.getId());
    Inventory.init(session);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:24,代码来源:InventoryTest.java


示例4: exec

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
protected boolean exec(Context context, Class<? extends Model> model, String sql) {
	DatabaseAdapter adapter = DatabaseAdapter.getInstance(context);
	
	adapter.open();
	
	try {
		adapter.exec(sql);
	} catch(SQLException e) {
		adapter.close();
	
		return false;
	}
	
	adapter.close();
	return true;
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:17,代码来源:DataField.java


示例5: deleteGroup

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
private void deleteGroup() {
    Context app = getApplication();
    DatabaseAdapter adapter = DatabaseAdapter.getInstance(app);
    Filter f;
    adapter.beginTransaction();
    for (Scripture scrip : deleteBook.getScriptures(app).all()) {
        scrip.delete(app);
    }
    f = new Filter().is("position", ">", deleteBook.getPosition());
    for (Book book : Book.objects(app).filter(f)) {
        book.setPosition(book.getPosition() - 1);
        book.save(app);
    }
    deleteBook.delete(app);
    adapter.commitTransaction();
    buildList();
    Toast.makeText(this, R.string.group_deleted,
            Toast.LENGTH_SHORT).show();
}
 
开发者ID:tooke7,项目名称:sm-helper,代码行数:20,代码来源:MainActivity.java


示例6: migrate

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
private static void migrate(Context app) {
    List<BookRecord> books;
    Book book;
    Scripture scrip;
    DatabaseAdapter adapter = DatabaseAdapter.getInstance(app);

    books = getOldBooks(app);
    adapter.beginTransaction();
    for (BookRecord bookRecord : books) {
        book = new Book();
        Log.d(SMApp.TAG, "migrating " + bookRecord.title);
        book.setTitle(bookRecord.title);
        book.setPreloaded(bookRecord.preloaded);
        for (ScripRecord scripRecord : bookRecord.scriptures) {
            scrip = new Scripture(scripRecord.ref,
                scripRecord.keywords, scripRecord.verses,
                scripRecord.status, scripRecord.finishedStreak);
            book.addScripture(scrip);
            scrip.save(app);
        }
        book.setRoutine(bookRecord, app);
        book.save(app);
    }
    adapter.commitTransaction();
    app.deleteDatabase(DBHandler.DB_NAME);
}
 
开发者ID:tooke7,项目名称:sm-helper,代码行数:27,代码来源:SyncDB.java


示例7: execute

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public boolean execute(Context context, Class<T> model) {
	if(isApplied(model, context)) {
		return false;
	}
	
	MigrationHelper helper = new MigrationHelper(context);
	
	if(!helper.tableExists(mOldName)) {
		// if the table, that should be renamed doesn't exist anymore
		// we have to assume, that this migration is rolled out on
		// a newer version of the database. Thus we need to save, that
		// it has already been applied, but must not run the command
		// on the database.
		return true;
	}
	
	DatabaseAdapter adapter = DatabaseAdapter.getInstance(context);
	
	renameRelationTables(context, model);
	
	try {
		adapter.renameTable(mOldName, getValue(model));
	} catch (SQLException e) {
		return false;
	}
	
	return true;
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:30,代码来源:RenameModelMigration.java


示例8: execute

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public boolean execute(Context context, Class<T> model) {
	MigrationHelper helper = new MigrationHelper(context);
	
	List<String> tables = helper.getRelationTableNames(mOldName);
	String newName = DatabaseBuilder.getTableName(model);

	mValue = StringUtils.join(tables, ",");
	
	if(isApplied(model, context)) {
		return false;
	}
	
	DatabaseAdapter adapter = DatabaseAdapter.getInstance(context);
	
	for(String table : tables) {
		List<String> parts = Arrays.asList(table.replace(mOldName, newName).split("_"));
		Collections.sort(parts);
		
		String name = StringUtils.join(parts, "_");
		
		try {
			adapter.renameTable(table, name);
		} catch(SQLException e) {
			return false;
		}
	}
	
	return true;
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:31,代码来源:RenameRelationMigration.java


示例9: setUp

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public void setUp() {
	List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
	models.add(EmptyModel.class);
	models.add(OneFieldModel.class);
	models.add(ModelWithRelation.class);
	
	DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
	adapter.setModels(models);
	
	super.setUp();
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:13,代码来源:MigrationHelperTest.java


示例10: setUp

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public void setUp() {
	List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
	models.add(EmptyModel.class);
	
	DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
	adapter.setModels(models);
	
	super.setUp();
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:11,代码来源:DataFieldMigrationTest.java


示例11: setUp

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public void setUp() {
	List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
	models.add(EmptyModel.class);
	models.add(ModelWithRelation.class);
	models.add(NewEmptyModel.class);
	models.add(NewModelWithRelation.class);
	
	DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
	adapter.setModels(models);
	
	super.setUp();
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:14,代码来源:RenameModelMigrationTest.java


示例12: testMigrationsRun

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
public void testMigrationsRun() {
	List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
	models.add(ModelWithMigration.class);
	
	DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
	adapter.setModels(models);
	
	assertTrue(mHelper.hasField(ModelWithMigration.class, "mTestField"));
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:10,代码来源:ModelTest.java


示例13: setUp

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public void setUp() {
	List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
	models.add(BlankModel.class);

	DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
	adapter.setModels(models);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:9,代码来源:TransactionTest.java


示例14: setUp

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public void setUp() {
	List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
	models.add(Product.class);
	models.add(Branch.class);
	models.add(Brand.class);
	models.add(Supplier.class);
	
	DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
	adapter.setModels(models);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:12,代码来源:ForeignKeyFieldTest.java


示例15: setUp

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public void setUp() {
	List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
	models.add(Brand.class);
	models.add(Branch.class);
	models.add(Product.class);
	
	DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
	adapter.setModels(models);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:11,代码来源:OneToManyFieldTest.java


示例16: setUp

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public void setUp() {
	List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
	models.add(Product.class);
	models.add(Supplier.class);
	models.add(Branch.class);
	models.add(Brand.class);
	
	DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
	adapter.setModels(models);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:12,代码来源:ManyToManyFieldTest.java


示例17: setUp

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
@Override
public void setUp() {
	List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
	models.add(BlankModel.class);
	models.add(BlankModelNoAutoincrement.class);
	
	DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
	adapter.setModels(models);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:10,代码来源:ModelTest.java


示例18: testHasField

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
public void testHasField() {
	assertFalse(ModelCache.modelHasField(BlankModel.class, "mName"));
	
	List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
	models.add(BlankModel.class);

	DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
	adapter.setModels(models);
	
	assertTrue(ModelCache.modelHasField(BlankModel.class, "mName"));
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:12,代码来源:FieldCacheTest.java


示例19: testFieldShortcur

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
public void testFieldShortcur() {
	assertNull(ModelCache.getField(BlankModelNoAutoincrement.class, "mName"));
	
	List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
	models.add(BlankModelNoAutoincrement.class);
	
	DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
	adapter.setModels(models);
	
	assertNotNull(ModelCache.getField(BlankModelNoAutoincrement.class, "mName"));
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:12,代码来源:FieldCacheTest.java


示例20: testTableDefinitionCache

import com.orm.androrm.DatabaseAdapter; //导入依赖的package包/类
public void testTableDefinitionCache() {
	assertFalse(ModelCache.knowsModel(Product.class));
	assertNull(ModelCache.getTableDefinitions(Product.class));
	
	List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
	models.add(Product.class);
	
	DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
	adapter.setModels(models);
	
	assertTrue(ModelCache.knowsModel(Product.class));
	assertNotNull(ModelCache.getTableDefinitions(Product.class));
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:14,代码来源:TableDefinitionCacheTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PacketUserauthFailure类代码示例发布时间:2022-05-22
下一篇:
Java ClassResolver类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap