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

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

本文整理了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

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

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

  1. public void testBuilderFromModel() {
  2. ContentProviderQueryBuilder builder = new ContentProviderQueryBuilder(TestSubqueryModel.PROPERTIES,
  3. TestSubqueryModel.SUBQUERY);
  4. Query query = builder.build(null, null, null, null);
  5. assertEquals(Arrays.asList(TestSubqueryModel.PROPERTIES), query.getFields());
  6. assertEquals(TestSubqueryModel.SUBQUERY, query.getTable());
  7. }

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

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

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

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

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

  1. public void testFrozenQueryWorksWithDatabase() {
  2. Query query = Query.select().limit(2).freeze();
  3. SquidCursor<Employee> cursor = database.query(Employee.class, query);
  4. try {
  5. assertEquals(2, cursor.getCount());
  6. assertNull(query.getTable());
  7. } finally {
  8. cursor.close();
  9. }
  10. Employee employee = database.fetchByQuery(Employee.class, query);
  11. assertNotNull(employee);
  12. assertNull(query.getTable());
  13. assertEquals(Field.field("2"), query.getLimit());
  14. }

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

  1. public void testSimpleSubquerySelect() {
  2. Query query = Query.fromSubquery(Query.select(Employee.NAME).from(Employee.TABLE), "subquery");
  3. StringProperty name = query.getTable().qualifyField(Employee.NAME);
  4. query.where(name.eq("bigBird"));
  5. SquidCursor<Employee> cursor = database.query(Employee.class, query);
  6. try {
  7. assertEquals(1, cursor.getCount());
  8. cursor.moveToFirst();
  9. Employee employee = new Employee(cursor);
  10. assertEquals("bigBird", employee.getName());
  11. } finally {
  12. cursor.close();
  13. }
  14. }

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

  1. public void testFetchByQueryResetsLimitAndTable() {
  2. TestModel model1 = new TestModel().setFirstName("Sam1").setLastName("Bosley1");
  3. TestModel model2 = new TestModel().setFirstName("Sam2").setLastName("Bosley2");
  4. TestModel model3 = new TestModel().setFirstName("Sam3").setLastName("Bosley3");
  5. database.persist(model1);
  6. database.persist(model2);
  7. database.persist(model3);
  8. Query query = Query.select().limit(2, 1);
  9. TestModel fetched = database.fetchByQuery(TestModel.class, query);
  10. assertEquals(model2.getRowId(), fetched.getRowId());
  11. assertEquals(Field.field("2"), query.getLimit());
  12. assertEquals(Field.field("1"), query.getOffset());
  13. assertEquals(null, query.getTable());
  14. }

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

  1. public void testSubqueryJoin() {
  2. StringProperty managerName = Employee.NAME.as("managerName");
  3. Query query = Query
  4. .fromSubquery(Query.select(Employee.MANAGER_ID).from(Employee.TABLE).groupBy(Employee.MANAGER_ID),
  5. "subquery");
  6. query.selectMore(managerName);
  7. query.join(Join.inner(Employee.TABLE, query.getTable().qualifyField(Employee.MANAGER_ID).eq(Employee.ID)))
  8. .orderBy(Employee.MANAGER_ID.asc());
  9. SquidCursor<Employee> cursor = database.query(Employee.class, query);
  10. try {
  11. assertEquals(3, cursor.getCount());
  12. cursor.moveToFirst();
  13. assertEquals("bigBird", cursor.get(managerName));
  14. cursor.moveToNext();
  15. assertEquals("cookieMonster", cursor.get(managerName));
  16. cursor.moveToNext();
  17. assertEquals("bert", cursor.get(managerName));
  18. } finally {
  19. cursor.close();
  20. }
  21. }

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

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

相关文章