本文整理汇总了Java中com.j256.ormlite.dao.RuntimeExceptionDao.queryForId方法的典型用法代码示例。如果您正苦于以下问题:Java RuntimeExceptionDao.queryForId方法的具体用法?Java RuntimeExceptionDao.queryForId怎么用?Java RuntimeExceptionDao.queryForId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.j256.ormlite.dao.RuntimeExceptionDao
的用法示例。
在下文中一共展示了RuntimeExceptionDao.queryForId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.j256.ormlite.dao.RuntimeExceptionDao; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments().containsKey(ARG_ITEM_ID)) {
// Load the dummy content specified by the fragment
// arguments. In a real-world scenario, use a Loader
// to load content from a content provider.
RuntimeExceptionDao<ChordData, Integer> simpleDao = getHelper().getSimpleDataDao();
//ChordData chord = new ChordData("draft", -1, -1, -1, -1, -1, -1);
//simpleDao.create(chord);
//showDetail(chord.id);
mItem = simpleDao.queryForId(Integer.parseInt(getArguments().getString(ARG_ITEM_ID)));
//mItem = DummyContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
}
}
示例2: testCustomRuntimeExceptionDao
import com.j256.ormlite.dao.RuntimeExceptionDao; //导入方法依赖的package包/类
public void testCustomRuntimeExceptionDao() throws Exception {
DatabaseHelper helper = new DatabaseHelper(getContext());
RuntimeExceptionDao<Foo, Integer> ourDao = helper.getRuntimeExceptionDao(Foo.class);
TableUtils.dropTable(helper.getConnectionSource(), Foo.class, true);
TableUtils.createTable(helper.getConnectionSource(), Foo.class);
try {
Foo foo = new Foo();
foo.stuff = "jfpfjewf";
assertEquals(1, ourDao.create(foo));
Foo result = ourDao.queryForId(foo.id);
assertNotNull(result);
assertEquals(foo.stuff, result.stuff);
} finally {
TableUtils.dropTable(helper.getConnectionSource(), Foo.class, true);
}
try {
// should throw a runtime exception
ourDao.queryForId(1);
fail("should have thrown");
} catch (RuntimeException e) {
// expected
}
}
示例3: getItemById
import com.j256.ormlite.dao.RuntimeExceptionDao; //导入方法依赖的package包/类
public static Item getItemById(UUID itemId) {
if (itemId != null) {
RuntimeExceptionDao<Item, UUID> itemDao = DsaTabApplication.getInstance().getDBHelper().getItemDao();
Item item = itemDao.queryForId(itemId);
return item;
} else {
return null;
}
}
示例4: getById
import com.j256.ormlite.dao.RuntimeExceptionDao; //导入方法依赖的package包/类
public static Person getById(ZulipApp app, int id) {
RuntimeExceptionDao<Person, Object> dao = app.getDao(Person.class);
return dao.queryForId(id);
}
示例5: findById
import com.j256.ormlite.dao.RuntimeExceptionDao; //导入方法依赖的package包/类
@Override
public <T, V> T findById(final Class<T> clzz, final V id) {
RuntimeExceptionDao dao = getRuntimeExceptionDao(translateClass(clzz));
return (T) dao.queryForId(id);
}