本文整理了Java中com.j256.ormlite.dao.Dao.queryForAll()
方法的一些代码示例,展示了Dao.queryForAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dao.queryForAll()
方法的具体详情如下:
包路径:com.j256.ormlite.dao.Dao
类名称:Dao
方法名:queryForAll
[英]Query for all of the items in the object table. For medium sized or large tables, this may load a lot of objects into memory so you should consider using the #iterator() method instead.
[中]查询对象表中的所有项。对于中等大小或较大的表,这可能会将大量对象加载到内存中,因此应该考虑使用“γ迭代器”()方法。
代码示例来源:origin: BaronZ88/MinimalistWeather
/**
* 查询表中的所有城市
*
* @return 城市列表数据
*/
public List<City> queryCityList() {
try {
return cityDaoOperation.queryForAll();
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
代码示例来源:origin: BaronZ88/MinimalistWeather
/**
* 查询所有热门城市
*
* @return 热门城市列表
*/
public List<HotCity> queryAllHotCity() {
try {
return hotCityDaoOperation.queryForAll();
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
}
代码示例来源:origin: magefree/mage
public List<Log> getAllLogs() {
List<Log> logs = new ArrayList<>();
try {
logs = logDao.queryForAll();
} catch (SQLException ex) {
}
return logs;
}
代码示例来源:origin: magefree/mage
public List<Feedback> getAllFeedbacks() {
List<Feedback> feedbacks = new ArrayList<>();
try {
feedbacks = feedbackDao.queryForAll();
} catch (SQLException ex) {
}
return feedbacks;
}
}
代码示例来源:origin: BaronZ88/MinimalistWeather
/**
* 查询数据库中的所有已添加的城市
*
* @return 结果集中只包括城市信息,天气数据不在其中
* @throws SQLException
*/
public List<Weather> queryAllSaveCity() throws SQLException {
return TransactionManager.callInTransaction(WeatherDatabaseHelper.getInstance(context).getConnectionSource(), () -> {
List<Weather> weatherList = weatherDaoOperation.queryForAll();
for (Weather weather : weatherList) {
String cityId = weather.getCityId();
weather.setAirQualityLive(apiDaoOperation.queryForId(cityId));
weather.setWeatherForecasts(forecastDaoOperation.queryForEq(WeatherForecast.CITY_ID_FIELD_NAME, cityId));
weather.setLifeIndexes(lifeIndexesDaoOperation.queryForEq(WeatherForecast.CITY_ID_FIELD_NAME, cityId));
weather.setWeatherLive(realTimeDaoOperation.queryForId(cityId));
}
return weatherList;
});
}
代码示例来源:origin: magefree/mage
public List<String> getClassNames() {
List<String> names = new ArrayList<>();
try {
List<CardInfo> results = cardDao.queryForAll();
for (CardInfo card : results) {
names.add(card.getClassName());
}
} catch (SQLException ex) {
Logger.getLogger(CardRepository.class).error("Error getting classnames from DB : " + ex);
}
return names;
}
代码示例来源:origin: magefree/mage
public List<String> getSetCodes() {
List<String> setCodes = new ArrayList<>();
try {
List<ExpansionInfo> expansions = expansionDao.queryForAll();
for (ExpansionInfo expansion : expansions) {
setCodes.add(expansion.getCode());
}
} catch (SQLException ex) {
logger.error("Can't get the expansion set codes from database.", ex);
return setCodes;
}
return setCodes;
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testDateStringFormatNotDayAlign() throws Exception {
Dao<DateStringFormat, Object> dao = createDao(DateStringFormat.class, true);
DateStringFormat dateStringFormat = new DateStringFormat();
dateStringFormat.date = new SimpleDateFormat("yyyy-MM-dd HH").parse("2012-09-01 12");
assertEquals(1, dao.create(dateStringFormat));
List<DateStringFormat> results = dao.queryForAll();
assertEquals(1, results.size());
assertFalse(dateStringFormat.date.equals(results.get(0).date));
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = Exception.class)
public void testCallBatchThrow() throws Exception {
final Dao<Foo, Integer> dao = createDao(Foo.class, true);
assertEquals(0, dao.queryForAll().size());
// this should be none
dao.callBatchTasks(new Callable<Void>() {
@Override
public Void call() throws Exception {
throw new Exception("for the hell of it");
}
});
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testExecuteRaw() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
Foo foo1 = new Foo();
assertEquals(1, dao.create(foo1));
Foo foo2 = new Foo();
assertEquals(1, dao.create(foo2));
assertEquals(2, dao.queryForAll().size());
dao.executeRaw("TRUNCATE TABLE FOO");
assertEquals(0, dao.queryForAll().size());
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testDefaultValue() throws Exception {
Dao<EnumDefault, Object> dao = createDao(EnumDefault.class, true);
EnumDefault enumDefault = new EnumDefault();
assertEquals(1, dao.create(enumDefault));
List<EnumDefault> unknowns = dao.queryForAll();
assertEquals(1, unknowns.size());
assertEquals(OurEnum.SECOND, unknowns.get(0).ourEnum);
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testBigDecimalNull() throws Exception {
Dao<LocalBigDecimal, Object> dao = createDao(LocalBigDecimal.class, true);
LocalBigDecimal foo = new LocalBigDecimal();
assertEquals(1, dao.create(foo));
List<LocalBigDecimal> results = dao.queryForAll();
assertEquals(1, results.size());
assertNull(results.get(0).bigDecimal);
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testLongPrimitiveNull() throws Exception {
Dao<LocalLongObj, Object> objDao = createDao(LocalLongObj.class, true);
LocalLongObj foo = new LocalLongObj();
foo.longField = null;
assertEquals(1, objDao.create(foo));
Dao<LocalLong, Object> dao = createDao(LocalLong.class, false);
List<LocalLong> all = dao.queryForAll();
assertEquals(1, all.size());
assertEquals(0, all.get(0).longField);
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testDoublePrimitiveNull() throws Exception {
Dao<LocalDoubleObj, Object> objDao = createDao(LocalDoubleObj.class, true);
LocalDoubleObj foo = new LocalDoubleObj();
foo.doubleField = null;
assertEquals(1, objDao.create(foo));
Dao<LocalDouble, Object> dao = createDao(LocalDouble.class, false);
List<LocalDouble> all = dao.queryForAll();
assertEquals(1, all.size());
assertEquals(0.0F, all.get(0).doubleField, 0.0F);
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testUnknownValueAnnotation() throws Exception {
Dao<LocalUnknownEnum, Object> dao = createDao(LocalUnknownEnum.class, true);
LocalUnknownEnum localUnknownEnum = new LocalUnknownEnum();
localUnknownEnum.ourEnum = OurEnum.SECOND;
assertEquals(1, dao.create(localUnknownEnum));
assertEquals(1, dao.updateRaw("UPDATE Foo set ourEnum = 'THIRD'"));
List<LocalUnknownEnum> unknowns = dao.queryForAll();
assertEquals(1, unknowns.size());
assertEquals(OurEnum.FIRST, unknowns.get(0).ourEnum);
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = SQLException.class)
public void testBigIntegerInvalidDbValue() throws Exception {
Dao<LocalBigInteger, Object> dao = createDao(LocalBigInteger.class, true);
Dao<NotBigInteger, Object> notDao = createDao(NotBigInteger.class, false);
NotBigInteger notFoo = new NotBigInteger();
notFoo.bigInteger = "not valid form";
assertEquals(1, notDao.create(notFoo));
dao.queryForAll();
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = SQLException.class)
public void testBigDecimalInvalidDbValue() throws Exception {
Dao<LocalBigDecimal, Object> dao = createDao(LocalBigDecimal.class, true);
Dao<NotBigDecimal, Object> notDao = createDao(NotBigDecimal.class, false);
NotBigDecimal notFoo = new NotBigDecimal();
notFoo.bigDecimal = "not valid form";
assertEquals(1, notDao.create(notFoo));
dao.queryForAll();
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = SQLException.class)
public void testUnknownEnumValue() throws Exception {
Dao<LocalEnumString, Object> dao = createDao(LocalEnumString.class, true);
LocalEnumString localEnumString = new LocalEnumString();
localEnumString.ourEnum = OurEnum.FIRST;
assertEquals(1, dao.create(localEnumString));
assertEquals(1, dao.updateRaw("UPDATE Foo set ourEnum = 'THIRD'"));
dao.queryForAll();
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testDeleteById() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
Foo foo = new Foo();
assertEquals(1, dao.create(foo));
assertNotNull(dao.queryForId(foo.id));
assertEquals(1, dao.deleteById(foo.id));
assertNull(dao.queryForId(foo.id));
assertEquals(0, dao.queryForAll().size());
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testDelete() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
Foo foo = new Foo();
assertEquals(1, dao.create(foo));
assertNotNull(dao.queryForId(foo.id));
assertEquals(1, dao.delete(foo));
assertNull(dao.queryForId(foo.id));
assertEquals(0, dao.queryForAll().size());
}
内容来源于网络,如有侵权,请联系作者删除!