org.greenrobot.greendao.query.Query.list()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(157)

本文整理了Java中org.greenrobot.greendao.query.Query.list方法的一些代码示例,展示了Query.list的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.list方法的具体详情如下:
包路径:org.greenrobot.greendao.query.Query
类名称:Query
方法名:list

Query.list介绍

[英]Executes the query and returns the result as a list containing all entities loaded into memory.
[中]执行查询并将结果作为包含加载到内存中的所有实体的列表返回。

代码示例

代码示例来源:origin: greenrobot/greenDAO

/**
 * Shorthand for {@link QueryBuilder#build() build()}.{@link Query#list() list()}; see {@link Query#list()} for
 * details. To execute a query more than once, you should build the query and keep the {@link Query} object for
 * efficiency reasons.
 */
public List<T> list() {
  return build().list();
}

代码示例来源:origin: greenrobot/greenDAO

@Override
  public List<T> call() throws Exception {
    return query.forCurrentThread().list();
  }
});

代码示例来源:origin: greenrobot/greenDAO

@Override
  public void run() {
    synchronized (query) {
      query.list();
    }
  }
});

代码示例来源:origin: greenrobot/greenDAO

@Override
  public void run() {
    query.list();
  }
});

代码示例来源:origin: greenrobot/greenDAO

@Override
  public void run() {
    query.list();
  }
});

代码示例来源:origin: greenrobot/greenDAO

@Override
  public void run() {
    query.forCurrentThread().list();
  }
};

代码示例来源:origin: greenrobot/greenDAO

@Override
  public void run() {
    query.forCurrentThread().list();
  }
};

代码示例来源:origin: greenrobot/greenDAO

@Override
  public void run() {
    try {
      queryHolder[0] = minimalEntityDao.queryBuilder().build();
      queryHolder[0].list();
    } finally {
      latch.countDown();
    }
  }
}.start();

代码示例来源:origin: greenrobot/greenDAO

/** Internal query to resolve the "toManyTarget2List" to-many relationship of RelationSource2. */
public List<ToManyTarget2> _queryRelationSource2_ToManyTarget2List(Long fkId) {
  synchronized (this) {
    if (relationSource2_ToManyTarget2ListQuery == null) {
      QueryBuilder<ToManyTarget2> queryBuilder = queryBuilder();
      queryBuilder.where(Properties.FkId.eq(null));
      relationSource2_ToManyTarget2ListQuery = queryBuilder.build();
    }
  }
  Query<ToManyTarget2> query = relationSource2_ToManyTarget2ListQuery.forCurrentThread();
  query.setParameter(0, fkId);
  return query.list();
}

代码示例来源:origin: greenrobot/greenDAO

/** Internal query to resolve the "children" to-many relationship of TreeEntity. */
public List<TreeEntity> _queryTreeEntity_Children(Long parentId) {
  synchronized (this) {
    if (treeEntity_ChildrenQuery == null) {
      QueryBuilder<TreeEntity> queryBuilder = queryBuilder();
      queryBuilder.where(Properties.ParentId.eq(null));
      treeEntity_ChildrenQuery = queryBuilder.build();
    }
  }
  Query<TreeEntity> query = treeEntity_ChildrenQuery.forCurrentThread();
  query.setParameter(0, parentId);
  return query.list();
}

代码示例来源:origin: greenrobot/greenDAO

public void testRawQueryEmptySql() {
  insert(3);
  Query<TestEntity> query = dao.queryRawCreate("");
  List<TestEntity> result = query.list();
  assertEquals(3, result.size());
}

代码示例来源:origin: greenrobot/greenDAO

/** Internal query to resolve the "toManyDescList" to-many relationship of ToManyEntity. */
public List<ToManyTargetEntity> _queryToManyEntity_ToManyDescList(Long toManyIdDesc) {
  synchronized (this) {
    if (toManyEntity_ToManyDescListQuery == null) {
      QueryBuilder<ToManyTargetEntity> queryBuilder = queryBuilder();
      queryBuilder.where(Properties.ToManyIdDesc.eq(null));
      queryBuilder.orderRaw("T.'_id' DESC");
      toManyEntity_ToManyDescListQuery = queryBuilder.build();
    }
  }
  Query<ToManyTargetEntity> query = toManyEntity_ToManyDescListQuery.forCurrentThread();
  query.setParameter(0, toManyIdDesc);
  return query.list();
}

代码示例来源:origin: greenrobot/greenDAO

/** Internal query to resolve the "dateEntityList" to-many relationship of ToManyEntity. */
public List<DateEntity> _queryToManyEntity_DateEntityList(Long idToMany) {
  synchronized (this) {
    if (toManyEntity_DateEntityListQuery == null) {
      QueryBuilder<DateEntity> queryBuilder = queryBuilder();
      queryBuilder.join(JoinManyToDateEntity.class, JoinManyToDateEntityDao.Properties.IdDate)
        .where(JoinManyToDateEntityDao.Properties.IdToMany.eq(idToMany));
      toManyEntity_DateEntityListQuery = queryBuilder.build();
    }
  }
  Query<DateEntity> query = toManyEntity_DateEntityListQuery.forCurrentThread();
  query.setParameter(0, idToMany);
  return query.list();
}

代码示例来源:origin: greenrobot/greenDAO

/** Internal query to resolve the "toManyTargetEntityList" to-many relationship of ToManyEntity. */
public List<ToManyTargetEntity> _queryToManyEntity_ToManyTargetEntityList(Long toManyId) {
  synchronized (this) {
    if (toManyEntity_ToManyTargetEntityListQuery == null) {
      QueryBuilder<ToManyTargetEntity> queryBuilder = queryBuilder();
      queryBuilder.where(Properties.ToManyId.eq(null));
      queryBuilder.orderRaw("T.'_id' ASC");
      toManyEntity_ToManyTargetEntityListQuery = queryBuilder.build();
    }
  }
  Query<ToManyTargetEntity> query = toManyEntity_ToManyTargetEntityListQuery.forCurrentThread();
  query.setParameter(0, toManyId);
  return query.list();
}

代码示例来源:origin: greenrobot/greenDAO

/** Internal query to resolve the "toManyByJoinProperty" to-many relationship of ToManyEntity. */
public List<ToManyTargetEntity> _queryToManyEntity_ToManyByJoinProperty(String targetJoinProperty) {
  synchronized (this) {
    if (toManyEntity_ToManyByJoinPropertyQuery == null) {
      QueryBuilder<ToManyTargetEntity> queryBuilder = queryBuilder();
      queryBuilder.where(Properties.TargetJoinProperty.eq(null));
      queryBuilder.orderRaw("T.'_id' ASC");
      toManyEntity_ToManyByJoinPropertyQuery = queryBuilder.build();
    }
  }
  Query<ToManyTargetEntity> query = toManyEntity_ToManyByJoinPropertyQuery.forCurrentThread();
  query.setParameter(0, targetJoinProperty);
  return query.list();
}

代码示例来源:origin: greenrobot/greenDAO

public void testRawQueryCreate_setParameterInQuery() {
  insert(3);
  String value = getSimpleString(2);
  String sql = "WHERE " + Properties.SimpleString.columnName + "=?";
  Query<TestEntity> query = dao.queryRawCreate(sql, getSimpleString(1));
  query.list();
  query.setParameter(0, value);
  List<TestEntity> result = query.list();
  assertEquals(1, result.size());
  assertEquals(value, result.get(0).getSimpleString());
}

代码示例来源:origin: greenrobot/greenDAO

public void testBuildTwice() {
  insert(3);
  String value = getSimpleString(1);
  QueryBuilder<TestEntity> builder = dao.queryBuilder().where(Properties.SimpleString.eq(value));
  Query<TestEntity> query1 = builder.build();
  Query<TestEntity> query2 = builder.build();
  List<TestEntity> list1 = query1.list();
  List<TestEntity> list2 = query2.list();
  assertEquals(1, list1.size());
  assertEquals(1, list2.size());
  assertEquals(list1.get(0).getId(), list2.get(0).getId());
}

代码示例来源:origin: greenrobot/greenDAO

public void testBuildQueryAndDeleteQuery() {
  insert(3);
  int value = getSimpleInteger(1);
  QueryBuilder<TestEntity> builder = dao.queryBuilder().where(Properties.SimpleInteger.eq(value));
  Query<TestEntity> query = builder.build();
  DeleteQuery<TestEntity> deleteQuery = builder.buildDelete();
  assertEquals(1, query.list().size());
  deleteQuery.executeDeleteWithoutDetachingEntities();
  assertEquals(0, query.list().size());
}

代码示例来源:origin: greenrobot/greenDAO

/** Internal query to resolve the "toManyJoinTwo" to-many relationship of ToManyEntity. */
public List<ToManyTargetEntity> _queryToManyEntity_ToManyJoinTwo(Long toManyId, String targetJoinProperty) {
  synchronized (this) {
    if (toManyEntity_ToManyJoinTwoQuery == null) {
      QueryBuilder<ToManyTargetEntity> queryBuilder = queryBuilder();
      queryBuilder.where(Properties.ToManyId.eq(null));
      queryBuilder.where(Properties.TargetJoinProperty.eq(null));
      queryBuilder.orderRaw("T.'TARGET_JOIN_PROPERTY' DESC,T.'_id' DESC");
      toManyEntity_ToManyJoinTwoQuery = queryBuilder.build();
    }
  }
  Query<ToManyTargetEntity> query = toManyEntity_ToManyJoinTwoQuery.forCurrentThread();
  query.setParameter(0, toManyId);
  query.setParameter(1, targetJoinProperty);
  return query.list();
}

代码示例来源:origin: greenrobot/greenDAO

public void testBuildQueryAndCountQuery() {
  insert(3);
  int value = getSimpleInteger(1);
  QueryBuilder<TestEntity> builder = dao.queryBuilder().where(Properties.SimpleInteger.eq(value));
  Query<TestEntity> query = builder.build();
  CountQuery<TestEntity> countQuery = builder.buildCount();
  assertEquals(1, query.list().size());
  assertEquals(1, countQuery.count());
}

相关文章