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

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

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

Where.query介绍

[英]A short-cut for calling QueryBuilder#query().
[中]调用QueryBuilder#query()的捷径。

代码示例

代码示例来源:origin: tianshaojie/AndroidFine

.query();
} catch (SQLException e)

代码示例来源:origin: TeamWalrus/Walrus

public static List<Card> filterCards(Dao<Card, ?> dao, String searchParameter) {
    try {
      return dao.queryBuilder()
          .where()
          .raw(Card.NAME_FIELD_NAME + " LIKE '%"
              + searchParameter.replaceAll("[\\\\%_]", "\\\\$0").replace("'", "''")
              + "%' ESCAPE '\\'")
          .query();
    } catch (SQLException e) {
      throw new RuntimeException(e);
    }
  }
}

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

public List<Tdao> getAll(String key, List<Tid> ids) {
  try {
    if (ids != null && !ids.isEmpty()) {
      return this.getDao().queryBuilder().where().in(key, ids).query();
    }
    return new ArrayList<Tdao>();
  } catch (SQLException ex) {
    _logger.error("unable to get all items ids:{}", ids, ex);
    return null;
  }
}

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

public List<Tdao> getAll(String key, List<Tid> ids) {
  try {
    if (ids != null && !ids.isEmpty()) {
      return this.getDao().queryBuilder().where().in(key, ids).query();
    }
    return new ArrayList<Tdao>();
  } catch (SQLException ex) {
    _logger.error("unable to get all items ids:{}", ids, ex);
    throw new McDatabaseException(ex);
  }
}

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

@Override
public List<T> queryForEq(String fieldName, Object value) throws SQLException {
  return queryBuilder().where().eq(fieldName, value).query();
}

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

public List<Tdao> getAll(String key, Object value) {
  try {
    return this.getDao().queryBuilder().where().eq(key, value).query();
  } catch (SQLException ex) {
    _logger.error("unable to get all items key:{}, value:{}", key, value, ex);
    return null;
  }
}

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

@Override
public List<SystemJob> getAllEnabled() {
  try {
    return this.getDao().queryBuilder().where()
        .eq(SystemJob.KEY_ENABLED, true).query();
  } catch (SQLException ex) {
    _logger.error("Unable to get list of enabled systemjobs", ex);
    return null;
  }
}

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

public List<Tdao> getAll(String key, Object value) {
  try {
    return this.getDao().queryBuilder().where().eq(key, value).query();
  } catch (SQLException ex) {
    _logger.error("unable to get all items key:{}, value:{}", key, value, ex);
    throw new McDatabaseException(ex);
  }
}

代码示例来源:origin: zulip/zulip-android

public static List<Person> getAllPeople(ZulipApp app) throws SQLException {
  RuntimeExceptionDao<Person, Object> dao = app.getDao(Person.class);
  return dao.queryBuilder().where().eq(Person.ISBOT_FIELD, false).query();
}

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

@Override
public List<Settings> getAll(Integer userId, String key) {
  try {
    return this.getDao().queryBuilder().where().eq(Settings.KEY_USER_ID, userId).and()
        .eq(Settings.KEY_KEY, key).query();
  } catch (SQLException ex) {
    _logger.error("unable to get item for userId:{}, Key:{}", userId, key, ex);
    return null;
  }
}

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

@Override
public List<Settings> getAll(Integer userId, String key) {
  try {
    return this.getDao().queryBuilder().where().eq(Settings.KEY_USER_ID, userId).and()
        .eq(Settings.KEY_KEY, key).query();
  } catch (SQLException ex) {
    _logger.error("unable to get item for userId:{}, Key:{}", userId, key, ex);
    throw new McDatabaseException(ex);
  }
}

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

@Override
public List<OperationTable> getByTimerIdEnabled(Integer timerId) {
  List<Integer> ids = DaoUtils.getOperationTimerMapDao().getOperationIdsByTimerId(timerId);
  try {
    return this.getDao().queryBuilder().where().in(OperationTable.KEY_ID, ids).and()
        .eq(OperationTable.KEY_ENABLED, true).query();
  } catch (SQLException ex) {
    _logger.error("Exception,", ex);
  }
  return null;
}

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

@Override
public List<OperationTable> getByRuleDefinitionIdEnabled(Integer ruleDefinitionId) {
  List<Integer> ids = DaoUtils.getOperationRuleDefinitionMapDao().getOperationIdsByRuleDefinitionId(
      ruleDefinitionId);
  try {
    return this.getDao().queryBuilder().where().in(OperationTable.KEY_ID, ids).and()
        .eq(OperationTable.KEY_ENABLED, true).query();
  } catch (SQLException ex) {
    _logger.error("Exception,", ex);
  }
  return null;
}

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

@Override
public List<OperationTable> getByRuleDefinitionIdEnabled(Integer ruleDefinitionId) {
  List<Integer> ids = DaoUtils.getOperationRuleDefinitionMapDao().getOperationIdsByRuleDefinitionId(
      ruleDefinitionId);
  try {
    return this.getDao().queryBuilder().where().in(OperationTable.KEY_ID, ids).and()
        .eq(OperationTable.KEY_ENABLED, true).query();
  } catch (SQLException ex) {
    _logger.error("Exception,", ex);
    throw new McDatabaseException(ex);
  }
}

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

@Override
public List<OperationTable> getByTimerIdEnabled(Integer timerId) {
  List<Integer> ids = DaoUtils.getOperationTimerMapDao().getOperationIdsByTimerId(timerId);
  try {
    return this.getDao().queryBuilder().where().in(OperationTable.KEY_ID, ids).and()
        .eq(OperationTable.KEY_ENABLED, true).query();
  } catch (SQLException ex) {
    _logger.error("Exception,", ex);
    throw new McDatabaseException(ex);
  }
}

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

@Test
public void testJeremyNull() throws Exception {
  Jeremy1 loop1 = new Jeremy1();
  Dao<Jeremy2, Long> dao = createDao(Jeremy2.class, true);
  List<Jeremy2> bars = dao.queryBuilder()
      .where()
      .eq(Jeremy2.LOOP1_COLUMN_NAME, loop1)
      .and()
      .eq(Jeremy2.OTHER_COLUMN_NAME, "someValue")
      .query();
  assertEquals(0, bars.size());
}

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

@Test
public void testNullForeign() throws Exception {
  Dao<OrderOrdered, Integer> orderDao = createDao(OrderOrdered.class, true);
  int numOrders = 10;
  for (int orderC = 0; orderC < numOrders; orderC++) {
    OrderOrdered order = new OrderOrdered();
    order.val = orderC;
    assertEquals(1, orderDao.create(order));
  }
  List<OrderOrdered> results = orderDao.queryBuilder().where().isNull(Order.ACCOUNT_FIELD_NAME).query();
  assertNotNull(results);
  assertEquals(numOrders, results.size());
}

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

@Test
public void testNullForeign() throws Exception {
  Dao<Order, Integer> orderDao = createDao(Order.class, true);
  int numOrders = 10;
  for (int orderC = 0; orderC < numOrders; orderC++) {
    Order order = new Order();
    order.val = orderC;
    assertEquals(1, orderDao.create(order));
  }
  List<Order> results = orderDao.queryBuilder().where().isNull(Order.ONE_FIELD_NAME).query();
  assertNotNull(results);
  assertEquals(numOrders, results.size());
}

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

@Test(expected = IllegalArgumentException.class)
public void testInnerQuerySubQueryPrepared() throws Exception {
  Dao<Foo, Integer> fooDao = createDao(Foo.class, true);
  fooDao.queryBuilder()
      .where()
      .in(Foo.ID_COLUMN_NAME,
          // this is a problem because prepare() returns a PreparedStmt not a QueryBuilder
          fooDao.queryBuilder().selectColumns(Foo.ID_COLUMN_NAME).prepare())
      .query();
}

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

@Test(expected = IllegalArgumentException.class)
public void testInnerQuerySubQueryWhere() throws Exception {
  Dao<Foo, Integer> fooDao = createDao(Foo.class, true);
  fooDao.queryBuilder()
      .where()
      .in(Foo.ID_COLUMN_NAME,
          // this is a problem because eq() returns a Where not a QueryBuilder
          fooDao.queryBuilder().selectColumns(Foo.ID_COLUMN_NAME).where().eq(Foo.ID_COLUMN_NAME, 1))
      .query();
}

相关文章