當前位置: 首頁>>代碼示例>>Java>>正文


Java Dao.queryForAll方法代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:SecUSo,項目名稱:privacy-friendly-shopping-list,代碼行數:17,代碼來源:AbstractDao.java

示例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;
}
 
開發者ID:Circle-Of-Music-Makers,項目名稱:com-android,代碼行數:20,代碼來源:DatabaseSynchronization.java

示例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();
        }
    }
 
開發者ID:Circle-Of-Music-Makers,項目名稱:com-android,代碼行數:17,代碼來源:MusicPlayerService.java

示例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();
  }
 
開發者ID:ByteWelder,項目名稱:Poetry,代碼行數:38,代碼來源:JsonTestCase.java

示例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;
}
 
開發者ID:Microsoft,項目名稱:EmbeddedSocial-Android-SDK,代碼行數:12,代碼來源:UserActionCache.java


注:本文中的com.j256.ormlite.dao.Dao.queryForAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。