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

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

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

Query.getTable介绍

暂无

代码示例

代码示例来源: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 testBuilderFromModel() {
  ContentProviderQueryBuilder builder = new ContentProviderQueryBuilder(TestSubqueryModel.PROPERTIES,
      TestSubqueryModel.SUBQUERY);
  Query query = builder.build(null, null, null, null);
  assertEquals(Arrays.asList(TestSubqueryModel.PROPERTIES), query.getFields());
  assertEquals(TestSubqueryModel.SUBQUERY, query.getTable());
}

代码示例来源: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 testSimpleSubquerySelect() {
  Query query = Query.fromSubquery(Query.select(Employee.NAME).from(Employee.TABLE), "subquery");
  StringProperty name = query.getTable().qualifyField(Employee.NAME);
  query.where(name.eq("bigBird"));
  SquidCursor<Employee> cursor = database.query(Employee.class, query);
  try {
    assertEquals(1, cursor.getCount());
    cursor.moveToFirst();
    Employee employee = new Employee(cursor);
    assertEquals("bigBird", employee.getName());
  } finally {
    cursor.close();
  }
}

代码示例来源: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: yahoo/squidb

public void testSubqueryJoin() {
  StringProperty managerName = Employee.NAME.as("managerName");
  Query query = Query
      .fromSubquery(Query.select(Employee.MANAGER_ID).from(Employee.TABLE).groupBy(Employee.MANAGER_ID),
          "subquery");
  query.selectMore(managerName);
  query.join(Join.inner(Employee.TABLE, query.getTable().qualifyField(Employee.MANAGER_ID).eq(Employee.ID)))
      .orderBy(Employee.MANAGER_ID.asc());
  SquidCursor<Employee> cursor = database.query(Employee.class, query);
  try {
    assertEquals(3, cursor.getCount());
    cursor.moveToFirst();
    assertEquals("bigBird", cursor.get(managerName));
    cursor.moveToNext();
    assertEquals("cookieMonster", cursor.get(managerName));
    cursor.moveToNext();
    assertEquals("bert", cursor.get(managerName));
  } finally {
    cursor.close();
  }
}

代码示例来源: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;
}

相关文章