@SuppressWarnings("unchecked") @Test public void testMixAndOrInline() throws Exception { Dao<Foo, String> dao = createDao(Foo.class, true); Foo foo1 = new Foo(); foo1.val = 10; foo1.stringField = "zip"; assertEquals(1, dao.create(foo1)); Foo foo2 = new Foo(); foo2.val = foo1.val; foo2.stringField = foo1.stringField + "zap"; assertEquals(1, dao.create(foo2)); QueryBuilder<Foo, String> qb = dao.queryBuilder(); Where<Foo, String> where = qb.where(); where.eq(Foo.VAL_COLUMN_NAME, foo1.val) .and() .eq(Foo.STRING_COLUMN_NAME, foo1.stringField) .or() .eq(Foo.STRING_COLUMN_NAME, foo2.stringField); List<Foo> results = dao.queryForAll(); assertEquals(2, results.size()); assertEquals(foo1.id, results.get(0).id); assertEquals(foo2.id, results.get(1).id); qb = dao.queryBuilder(); where = qb.where(); where.and(where.eq(Foo.VAL_COLUMN_NAME, foo1.val), where.or(where.eq(Foo.STRING_COLUMN_NAME, foo1.stringField), where.eq(Foo.STRING_COLUMN_NAME, foo2.stringField))); results = dao.queryForAll(); assertEquals(2, results.size()); assertEquals(foo1.id, results.get(0).id); assertEquals(foo2.id, results.get(1).id); qb = dao.queryBuilder(); where = qb.where(); where.eq(Foo.VAL_COLUMN_NAME, foo1.val); where.and(); where.eq(Foo.STRING_COLUMN_NAME, foo1.stringField); where.or(); where.eq(Foo.STRING_COLUMN_NAME, foo2.stringField); results = dao.queryForAll(); assertEquals(2, results.size()); assertEquals(foo1.id, results.get(0).id); assertEquals(foo2.id, results.get(1).id); qb = dao.queryBuilder(); where = qb.where(); where.eq(Foo.VAL_COLUMN_NAME, foo1.val); where.eq(Foo.STRING_COLUMN_NAME, foo1.stringField); where.eq(Foo.STRING_COLUMN_NAME, foo2.stringField); where.or(2); where.and(2); results = dao.queryForAll(); assertEquals(2, results.size()); assertEquals(foo1.id, results.get(0).id); assertEquals(foo2.id, results.get(1).id); }
public QueryBuilder(DatabaseType databaseType, TableInfo<T, ID> tableInfo, Dao<T, ID> dao) { super(databaseType, tableInfo, dao, StatementType.SELECT); this.idField = tableInfo.getIdField(); this.selectIdColumn = (idField != null); }
QueryBuilder extends StatementBuilder<T, ID> { public QueryBuilder(DatabaseType databaseType, TableInfo<T, ID> tableInfo, Dao<T, ID> dao) { super(databaseType, tableInfo, dao, StatementType.SELECT); this.idField = tableInfo.getIdField(); this.selectIdColumn = (idField != null); } }
QueryBuilder extends StatementBuilder<T, ID> { public QueryBuilder(DatabaseType databaseType, TableInfo<T, ID> tableInfo, Dao<T, ID> dao) { super(databaseType, tableInfo, dao, StatementType.SELECT); this.idField = tableInfo.getIdField(); this.selectIdColumn = (idField != null); } QueryBuilder(DatabaseType databaseType, TableInfo<T, ID> tableInfo, Dao<T, ID> dao); }
QueryBuilder extends StatementBuilder<T, ID> { public QueryBuilder(DatabaseType databaseType, TableInfo<T, ID> tableInfo, Dao<T, ID> dao) { super(databaseType, tableInfo, dao, StatementType.SELECT); this.idField = tableInfo.getIdField(); this.selectIdColumn = (idField != null); } QueryBuilder(DatabaseType databaseType, TableInfo<T, ID> tableInfo, Dao<T, ID> dao); PreparedQuery<T> prepare(); QueryBuilder<T, ID> selectColumns(String... columns); QueryBuilder<T, ID> selectColumns(Iterable<String> columns); QueryBuilder<T, ID> selectRaw(String... columns); QueryBuilder<T, ID> groupBy(String columnName); QueryBuilder<T, ID> groupByRaw(String rawSql); QueryBuilder<T, ID> orderBy(String columnName, boolean ascending); QueryBuilder<T, ID> orderByRaw(String rawSql); QueryBuilder<T, ID> orderByRaw(String rawSql, ArgumentHolder... args); QueryBuilder<T, ID> distinct(); QueryBuilder<T, ID> limit(Long maxRows); QueryBuilder<T, ID> offset(Long startRow); QueryBuilder<T, ID> setCountOf(boolean countOf); QueryBuilder<T, ID> setCountOf(String countOfQuery); QueryBuilder<T, ID> having(String having); QueryBuilder<T, ID> join(QueryBuilder<?, ?> joinedQueryBuilder); QueryBuilder<T, ID> join(QueryBuilder<?, ?> joinedQueryBuilder, JoinType type, JoinWhereOperation operation); QueryBuilder<T, ID> joinOr(QueryBuilder<?, ?> joinedQueryBuilder); QueryBuilder<T, ID> leftJoin(QueryBuilder<?, ?> joinedQueryBuilder); QueryBuilder<T, ID> leftJoinOr(QueryBuilder<?, ?> joinedQueryBuilder); QueryBuilder<T, ID> join(String localColumnName, String joinedColumnName,
			QueryBuilder<?, ?> joinedQueryBuilder); QueryBuilder<T, ID> join(String localColumnName, String joinedColumnName,
			QueryBuilder<?, ?> joinedQueryBuilder, JoinType type, JoinWhereOperation operation); List<T> query(); GenericRawResults<String[]> queryRaw(); T queryForFirst(); String[] queryRawFirst(); CloseableIterator<T> iterator(); long countOf(); long countOf(String countOfQuery); QueryBuilder<T, ID> setAlias(String alias); @Override void reset(); }
QueryBuilder extends StatementBuilder<T, ID> { public QueryBuilder(DatabaseType databaseType, TableInfo<T, ID> tableInfo, Dao<T, ID> dao) { super(databaseType, tableInfo, dao, StatementType.SELECT); this.idField = tableInfo.getIdField(); this.selectIdColumn = (idField != null); } QueryBuilder(DatabaseType databaseType, TableInfo<T, ID> tableInfo, Dao<T, ID> dao); PreparedQuery<T> prepare(); QueryBuilder<T, ID> selectColumns(String... columns); QueryBuilder<T, ID> selectColumns(Iterable<String> columns); QueryBuilder<T, ID> selectRaw(String... columns); QueryBuilder<T, ID> groupBy(String columnName); QueryBuilder<T, ID> groupByRaw(String rawSql); QueryBuilder<T, ID> orderBy(String columnName, boolean ascending); QueryBuilder<T, ID> orderByRaw(String rawSql); QueryBuilder<T, ID> orderByRaw(String rawSql, ArgumentHolder... args); QueryBuilder<T, ID> distinct(); QueryBuilder<T, ID> limit(Long maxRows); QueryBuilder<T, ID> offset(Long startRow); QueryBuilder<T, ID> setCountOf(boolean countOf); QueryBuilder<T, ID> setCountOf(String countOfQuery); QueryBuilder<T, ID> having(String having); QueryBuilder<T, ID> join(QueryBuilder<?, ?> joinedQueryBuilder); QueryBuilder<T, ID> join(QueryBuilder<?, ?> joinedQueryBuilder, JoinType type, JoinWhereOperation operation); QueryBuilder<T, ID> joinOr(QueryBuilder<?, ?> joinedQueryBuilder); QueryBuilder<T, ID> leftJoin(QueryBuilder<?, ?> joinedQueryBuilder); QueryBuilder<T, ID> leftJoinOr(QueryBuilder<?, ?> joinedQueryBuilder); QueryBuilder<T, ID> join(String localColumnName, String joinedColumnName,
			QueryBuilder<?, ?> joinedQueryBuilder); QueryBuilder<T, ID> join(String localColumnName, String joinedColumnName,
			QueryBuilder<?, ?> joinedQueryBuilder, JoinType type, JoinWhereOperation operation); List<T> query(); GenericRawResults<String[]> queryRaw(); T queryForFirst(); String[] queryRawFirst(); CloseableIterator<T> iterator(); long countOf(); long countOf(String countOfQuery); QueryBuilder<T, ID> setAlias(String alias); @Override void reset();  }