当前位置: 首页>>代码示例>>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;未经允许,请勿转载。