com.yahoo.squidb.sql.Query.getLimit()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(231)

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

Query.getLimit介绍

暂无

代码示例

代码示例来源:origin: yahoo/squidb

protected <TYPE extends AbstractModel> SquidCursor<TYPE> fetchFirstItem(Class<TYPE> modelClass, Query query) {
  boolean immutableQuery = query.isImmutable();
  Field<Integer> beforeLimit = query.getLimit();
  SqlTable<?> beforeTable = query.getTable();
  query = query.limit(1); // If argument was frozen, we may get a new object
  SquidCursor<TYPE> cursor = query(modelClass, query);
  if (!immutableQuery) {
    query.from(beforeTable).limit(beforeLimit); // Reset for user
  }
  cursor.moveToFirst();
  return cursor;
}

代码示例来源:origin: yahoo/squidb

public void testQueryFreeze() {
  Query base = Query.select().from(Employee.TABLE).limit(1).freeze();
  Query fork = base.limit(2);
  assertFalse(base == fork);
  assertEquals(Field.field("1"), base.getLimit());
  assertEquals(Field.field("2"), fork.getLimit());
  assertEquals(base.getTable(), fork.getTable());
}

代码示例来源:origin: yahoo/squidb

public void testFork() {
  Query base = Query.select().from(Employee.TABLE).limit(1);
  Query fork = base.fork().limit(2);
  base.limit(3);
  assertFalse(base == fork);
  assertEquals(Field.field("3"), base.getLimit());
  assertEquals(Field.field("2"), fork.getLimit());
  assertEquals(base.getTable(), fork.getTable());
}

代码示例来源:origin: yahoo/squidb

public void testFrozenQueryWorksWithDatabase() {
  Query query = Query.select().limit(2).freeze();
  SquidCursor<Employee> cursor = database.query(Employee.class, query);
  try {
    assertEquals(2, cursor.getCount());
    assertNull(query.getTable());
  } finally {
    cursor.close();
  }
  Employee employee = database.fetchByQuery(Employee.class, query);
  assertNotNull(employee);
  assertNull(query.getTable());
  assertEquals(Field.field("2"), query.getLimit());
}

代码示例来源:origin: yahoo/squidb

public void testFetchByQueryResetsLimitAndTable() {
  TestModel model1 = new TestModel().setFirstName("Sam1").setLastName("Bosley1");
  TestModel model2 = new TestModel().setFirstName("Sam2").setLastName("Bosley2");
  TestModel model3 = new TestModel().setFirstName("Sam3").setLastName("Bosley3");
  database.persist(model1);
  database.persist(model2);
  database.persist(model3);
  Query query = Query.select().limit(2, 1);
  TestModel fetched = database.fetchByQuery(TestModel.class, query);
  assertEquals(model2.getRowId(), fetched.getRowId());
  assertEquals(Field.field("2"), query.getLimit());
  assertEquals(Field.field("1"), query.getOffset());
  assertEquals(null, query.getTable());
}

代码示例来源:origin: com.yahoo.squidb/squidb

protected <TYPE extends AbstractModel> SquidCursor<TYPE> fetchFirstItem(Class<TYPE> modelClass, Query query) {
  boolean immutableQuery = query.isImmutable();
  Field<Integer> beforeLimit = query.getLimit();
  SqlTable<?> beforeTable = query.getTable();
  query = query.limit(1); // If argument was frozen, we may get a new object
  SquidCursor<TYPE> cursor = query(modelClass, query);
  if (!immutableQuery) {
    query.from(beforeTable).limit(beforeLimit); // Reset for user
  }
  cursor.moveToFirst();
  return cursor;
}

相关文章