本文整理汇总了Java中com.j256.ormlite.dao.Dao.queryForAll方法的典型用法代码示例。如果您正苦于以下问题:Java Dao.queryForAll方法的具体用法?Java Dao.queryForAll怎么用?Java Dao.queryForAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.j256.ormlite.dao.Dao
的用法示例。
在下文中一共展示了Dao.queryForAll方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllEntities
import com.j256.ormlite.dao.Dao; //导入方法依赖的package包/类
protected List<T> getAllEntities(Class<T> type)
{
List<T> entities;
try
{
Dao<T, Long> dao = database.getDao(type);
entities = dao.queryForAll();
PFALogger.debug(getClass().getName(), GET_ALL_ENTITIES, SUCCESSFUL);
return entities;
}
catch ( SQLException e )
{
PFALogger.error(getClass().getName(), GET_ALL_ENTITIES, e);
return null;
}
}
示例2: doInBackground
import com.j256.ormlite.dao.Dao; //导入方法依赖的package包/类
@Override
protected Void doInBackground(Void... voids) {
ArrayList<Track> mTrackList = Utils.musicLoader(mContext);
OrmHandler ormHandler = OpenHelperManager.getHelper(mContext, OrmHandler.class);
try {
Dao<Track, String> dbTrack = ormHandler.getDao(Track.class);
List<Track> _temp = dbTrack.queryForAll();
_temp.removeAll(mTrackList);
for (Track t :
mTrackList) {
dbTrack.createIfNotExists(t);
}
dbTrack.delete(_temp);
} catch (SQLException e) {
e.printStackTrace();
}
OpenHelperManager.releaseHelper();
return null;
}
示例3: onCreate
import com.j256.ormlite.dao.Dao; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
// This is here because onStart is not called when BIND_AUTO_CREATE is used
mContext = this;
localBroadcastManager = LocalBroadcastManager.getInstance(this);
final OrmHandler ormHandler = OpenHelperManager.getHelper(this, OrmHandler.class);
Dao<Track, String> dbTrack;
try {
dbTrack = ormHandler.getDao(Track.class);
mTrackList = dbTrack.queryForAll();
mBucketList = dbTrack.queryForEq("bucket", true);
} catch (SQLException e) {
e.printStackTrace();
}
}
示例4: testJsonMapper
import com.j256.ormlite.dao.Dao; //导入方法依赖的package包/类
public void testJsonMapper() throws Exception
{
DatabaseHelper helper = DatabaseHelper.getHelper(getContext());
// Load JSON
JSONObject json = JsonLoader.loadObject(getContext(), poetry.test.R.raw.test);
// Get child arrays from JSON
JSONArray users_json = JsonPathResolver.resolveArray(json, "users");
JSONArray groups_json = JsonPathResolver.resolveArray(json, "groups");
// Persist arrays to database
JsonPersister persister = new JsonPersister(helper.getWritableDatabase());
persister.persistArray(User.class, users_json);
persister.persistArray(Group.class, groups_json);
Dao<User, Integer> user_dao = helper.getDao(User.class);
Dao<Group, Integer> group_dao = helper.getDao(Group.class);
List<User> users = user_dao.queryForAll();
assertEquals(2, users.size());
List<Group> groups = group_dao.queryForAll();
assertEquals(3, groups.size());
User user = user_dao.queryForId(1);
assertNotNull(user);
assertEquals("John", user.getName());
assertEquals(2, user.getTags().size());
assertEquals("tag2", user.getTags().get(1));
Group group = group_dao.queryForId(2);
assertNotNull(group);
assertEquals("Group B", group.getName());
DatabaseHelper.releaseHelper();
}
示例5: queryForAllItems
import com.j256.ormlite.dao.Dao; //导入方法依赖的package包/类
private <T> List<T> queryForAllItems(Dao<T, Integer> dao) {
List<T> result;
try {
result = dao.queryForAll();
} catch (SQLException e) {
result = Collections.emptyList();
}
return result;
}