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

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

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

Where.isNotNull介绍

[英]Add a 'IS NOT NULL' clause so the column must not be null. '<>' NULL does not work.
[中]添加一个'IS NOT NULL'子句,使列不能为NULL。<>'空值不起作用。

代码示例

代码示例来源:origin: magefree/mage

public boolean cardExists(String className) {
  try {
    if (classNames == null) {
      QueryBuilder<CardInfo, Object> qb = cardDao.queryBuilder();
      qb.distinct().selectColumns("className").where().isNotNull("className");
      List<CardInfo> results = cardDao.query(qb.prepare());
      classNames = new TreeSet<>();
      for (CardInfo card : results) {
        classNames.add(card.getClassName());
      }
    }
    return classNames.contains(className);
  } catch (SQLException ex) {
  }
  return false;
}

代码示例来源:origin: magefree/mage

public boolean cardExists(CardSetInfo className) {
  try {
    if (classNames == null) {
      QueryBuilder<CardInfo, Object> qb = cardDao.queryBuilder();
      qb.distinct().selectColumns("className").where().isNotNull("className");
      List<CardInfo> results = cardDao.query(qb.prepare());
      classNames = new TreeSet<>();
      for (CardInfo card : results) {
        classNames.add(card.getClassName());
      }
    }
    return classNames.contains(className.getName());
  } catch (SQLException ex) {
  }
  return false;
}

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

@Test
public void testIsNotNull() throws Exception {
  Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null, databaseType);
  where.isNotNull(Foo.VAL_COLUMN_NAME);
  StringBuilder whereSb = new StringBuilder();
  where.appendSql(null, whereSb, new ArrayList<ArgumentHolder>());
  StringBuilder sb = new StringBuilder();
  databaseType.appendEscapedEntityName(sb, Foo.VAL_COLUMN_NAME);
  sb.append(" IS NOT NULL ");
  assertEquals(sb.toString(), whereSb.toString());
}

代码示例来源:origin: annmuor/jnode

break;
case "notnull":
  wh.isNotNull(args[i].toString());
  i -= 1;
  break;

代码示例来源:origin: com.j256.ormlite/ormlite-jdbc

@Test
public void testIsNull() throws Exception {
  Dao<Foo, String> fooDao = createTestData();
  QueryBuilder<Foo, String> qb = fooDao.queryBuilder();
  // null fields start off as null so 0 are not-null
  qb.where().isNotNull(Foo.NULL_COLUMN_NAME);
  List<Foo> results = fooDao.query(qb.prepare());
  assertEquals(0, results.size());
  // all are null
  qb.where().isNull(Foo.NULL_COLUMN_NAME);
  results = fooDao.query(qb.prepare());
  assertEquals(2, results.size());
  assertEquals(foo1, results.get(0));
  assertEquals(foo2, results.get(1));
  // set the null fields to not-null
  for (Foo foo : results) {
    foo.nullField = "not null";
    assertEquals(1, fooDao.update(foo));
  }
  // no null results should be found
  qb.where().isNull(Foo.NULL_COLUMN_NAME);
  results = fooDao.query(qb.prepare());
  assertEquals(0, results.size());
  // all are not-null
  qb.where().isNotNull(Foo.NULL_COLUMN_NAME);
  results = fooDao.query(qb.prepare());
  assertEquals(2, results.size());
  assertEquals(foo1, results.get(0));
  assertEquals(foo2, results.get(1));
}

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

@Test
public void testRandomIsNull() throws Exception {
  Dao<SeralizableNull, Integer> dao = createDao(SeralizableNull.class, true);
  SeralizableNull sn1 = new SeralizableNull();
  assertEquals(1, dao.create(sn1));
  SeralizableNull sn2 = new SeralizableNull();
  sn2.serializable = "wow";
  assertEquals(1, dao.create(sn2));
  List<SeralizableNull> results =
      dao.queryBuilder().where().isNull(SeralizableNull.FIELD_NAME_SERIALIZABLE).query();
  assertNotNull(results);
  assertEquals(1, results.size());
  assertEquals(sn1.id, results.get(0).id);
  results = dao.queryBuilder().where().isNotNull(SeralizableNull.FIELD_NAME_SERIALIZABLE).query();
  assertNotNull(results);
  assertEquals(1, results.size());
  assertEquals(sn2.id, results.get(0).id);
}

代码示例来源:origin: org.mycontroller.standalone/mycontroller-core

where.isNotNull(ResourcesLogs.KEY_ID);

代码示例来源:origin: mycontroller-org/mycontroller

where.isNotNull(ResourcesLogs.KEY_ID);

相关文章