예제 #1
0
 public List<Promotion> getPromotionTicker() {
   List<Promotion> result = new ArrayList<>();
   try {
     Dao<Promotion, String> dao = this.getController();
     QueryBuilder<Promotion, String> builder = dao.queryBuilder();
     builder.limit(10);
     builder.orderBy("createDate", false);
     result = dao.query(builder.prepare()); // returns list of ten items
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return result;
 }
 @Override
 @Test
 public void testLimitFormat() throws Exception {
   connectionSource.setDatabaseType(databaseType);
   BaseDaoImpl<StringId, String> dao =
       new BaseDaoImpl<StringId, String>(connectionSource, StringId.class) {};
   dao.initialize();
   QueryBuilder<StringId, String> qb = dao.queryBuilder();
   long limit = 1232;
   qb.limit(limit);
   String query = qb.prepareStatementString();
   assertTrue(
       query + " should start with stuff", query.startsWith("SELECT LIMIT 0 " + limit + " "));
 }
예제 #3
0
 @Override
 public RedmineWiki fetchItemByProject(int connection_id, long project_id, long offset, long limit)
     throws SQLException {
   QueryBuilder<RedmineWiki, ?> builder = dao.queryBuilder();
   builder
       .limit(limit)
       .offset(offset)
       .orderBy(RedmineWiki.TITLE, true)
       .where()
       .eq(RedmineWiki.CONNECTION, connection_id)
       .and()
       .eq(RedmineWiki.PROJECT_ID, project_id);
   RedmineWiki item = builder.queryForFirst();
   if (item == null) item = new RedmineWiki();
   return item;
 }