@Test public void getCount_simpleQuery_returnsFour() throws SQLException { FreeformQuery query = new FreeformQuery("SELECT * FROM people", Arrays.asList("ID"), connectionPool); Assert.assertEquals(4, query.getCount()); }
@Override public int getCount() throws SQLException { int count = countByDelegate(); if (count < 0) { Statement statement = null; ResultSet rs = null; Connection conn = getConnection(); try { statement = conn.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = statement.executeQuery(queryString); if (rs.last()) { count = rs.getRow(); } else { count = 0; } } finally { releaseConnection(conn, statement, rs); } } return count; }
FreeformQuery extends AbstractTransactionalQuery implements
        QueryDelegate { @Override public int getCount() throws SQLException { int count = countByDelegate(); if (count < 0) { Statement statement = null; ResultSet rs = null; Connection conn = getConnection(); try { statement = conn.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = statement.executeQuery(queryString); if (rs.last()) { count = rs.getRow(); } else { count = 0; } } finally { releaseConnection(conn, statement, rs); } } return count; } }
FreeformQuery extends AbstractTransactionalQuery implements
        QueryDelegate { @Override public int getCount() throws SQLException { int count = countByDelegate(); if (count < 0) { Statement statement = null; ResultSet rs = null; Connection conn = getConnection(); try { statement = conn.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = statement.executeQuery(queryString); if (rs.last()) { count = rs.getRow(); } else { count = 0; } } finally { releaseConnection(conn, statement, rs); } } return count; } @SuppressWarnings("unused") private  FreeformQuery(); @Deprecated  FreeformQuery(String queryString, List<String> primaryKeyColumns,
            JDBCConnectionPool connectionPool);  FreeformQuery(String queryString, JDBCConnectionPool connectionPool,
            String... primaryKeyColumns); }
FreeformQuery extends AbstractTransactionalQuery implements
        QueryDelegate { @Override public int getCount() throws SQLException { int count = countByDelegate(); if (count < 0) { Statement statement = null; ResultSet rs = null; Connection conn = getConnection(); try { statement = conn.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = statement.executeQuery(queryString); if (rs.last()) { count = rs.getRow(); } else { count = 0; } } finally { releaseConnection(conn, statement, rs); } } return count; } @SuppressWarnings("unused") private  FreeformQuery(); @Deprecated  FreeformQuery(String queryString, List<String> primaryKeyColumns,
            JDBCConnectionPool connectionPool);  FreeformQuery(String queryString, JDBCConnectionPool connectionPool,
            String... primaryKeyColumns); @Override int getCount(); @Override @SuppressWarnings({ "deprecation", "finally" }) ResultSet getResults(int offset, int pagelength); @Override @SuppressWarnings("deprecation") boolean implementationRespectsPagingLimits(); @Override void setFilters(List<Filter> filters); @Override void setOrderBy(List<OrderBy> orderBys); @Override int storeRow(RowItem row); @Override boolean removeRow(RowItem row); @Override synchronized void beginTransaction(); @Override synchronized void commit(); @Override synchronized void rollback(); @Override List<String> getPrimaryKeyColumns(); String getQueryString(); FreeformQueryDelegate getDelegate(); void setDelegate(FreeformQueryDelegate delegate); @Override @SuppressWarnings("deprecation") boolean containsRowWithKey(Object... keys); }
FreeformQuery extends AbstractTransactionalQuery implements
        QueryDelegate { @Override public int getCount() throws SQLException { int count = countByDelegate(); if (count < 0) { Statement statement = null; ResultSet rs = null; Connection conn = getConnection(); try { statement = conn.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = statement.executeQuery(queryString); if (rs.last()) { count = rs.getRow(); } else { count = 0; } } finally { releaseConnection(conn, statement, rs); } } return count; } @SuppressWarnings("unused") private  FreeformQuery(); @Deprecated  FreeformQuery(String queryString, List<String> primaryKeyColumns,
            JDBCConnectionPool connectionPool);  FreeformQuery(String queryString, JDBCConnectionPool connectionPool,
            String... primaryKeyColumns); @Override int getCount(); @Override @SuppressWarnings({ "deprecation", "finally" }) ResultSet getResults(int offset, int pagelength); @Override @SuppressWarnings("deprecation") boolean implementationRespectsPagingLimits(); @Override void setFilters(List<Filter> filters); @Override void setOrderBy(List<OrderBy> orderBys); @Override int storeRow(RowItem row); @Override boolean removeRow(RowItem row); @Override synchronized void beginTransaction(); @Override synchronized void commit(); @Override synchronized void rollback(); @Override List<String> getPrimaryKeyColumns(); String getQueryString(); FreeformQueryDelegate getDelegate(); void setDelegate(FreeformQueryDelegate delegate); @Override @SuppressWarnings("deprecation") boolean containsRowWithKey(Object... keys);  }