com.j256.ormlite.stmt.Where.notIn()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(168)

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

Where.notIn介绍

[英]Same as #in(String,QueryBuilder) except with a NOT IN clause.
[中]与#in(String,QueryBuilder)相同,只是带有NOT in子句。

代码示例

代码示例来源:origin: QuickBlox/q-municate-android

public List<Friend> getAllForGroupDetails(List<Integer> idsList) {
  List<Friend> friendsList = Collections.emptyList();
  try {
    QueryBuilder<Friend, Long> queryBuilder = dao.queryBuilder();
    queryBuilder.where().notIn(QMUserColumns.ID, idsList);
    PreparedQuery<Friend> preparedQuery = queryBuilder.prepare();
    friendsList = dao.query(preparedQuery);
  } catch (SQLException e) {
    ErrorUtils.logError(e);
  }
  return friendsList;
}

代码示例来源:origin: j256/ormlite-core

@Test
public void testNotIn() throws Exception {
  Dao<Foo, String> dao = createDao(Foo.class, true);
  Foo foo1 = new Foo();
  foo1.val = 63465365;
  assertEquals(1, dao.create(foo1));
  Foo foo2 = new Foo();
  foo2 = new Foo();
  foo2.val = 163123;
  assertEquals(1, dao.create(foo2));
  List<Foo> results = dao.queryBuilder().where().in(Foo.ID_COLUMN_NAME, foo2.id).query();
  assertEquals(1, results.size());
  assertEquals(foo2.val, results.get(0).val);
  // support not with in
  results = dao.queryBuilder().where().not().in(Foo.ID_COLUMN_NAME, foo2.id).query();
  assertEquals(1, results.size());
  assertEquals(foo1.val, results.get(0).val);
  // support not in
  results = dao.queryBuilder().where().notIn(Foo.ID_COLUMN_NAME, foo2.id).query();
  assertEquals(1, results.size());
  assertEquals(foo1.val, results.get(0).val);
}

代码示例来源:origin: j256/ormlite-core

@Test
public void testInSubQueryForReal() throws Exception {
  Dao<Foo, Integer> dao = createDao(Foo.class, true);
  Foo foo1 = new Foo();
  foo1.val = 785463547;
  assertEquals(1, dao.create(foo1));
  Foo foo2 = new Foo();
  foo2.val = 163547;
  assertEquals(1, dao.create(foo2));
  QueryBuilder<Foo, Integer> qb = dao.queryBuilder();
  qb.selectColumns(Foo.ID_COLUMN_NAME);
  qb.where().eq(Foo.VAL_COLUMN_NAME, foo2.val);
  List<Foo> results = dao.queryBuilder().where().in(Foo.ID_COLUMN_NAME, qb).query();
  assertEquals(1, results.size());
  assertEquals(foo2.val, results.get(0).val);
  // test not in with sub query
  results = dao.queryBuilder().where().notIn(Foo.ID_COLUMN_NAME, qb).query();
  assertEquals(1, results.size());
  assertEquals(foo1.val, results.get(0).val);
}

相关文章