@Test public void getCount_normalState_releasesConnection() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, SQLTestsConstants.sqlGen); tQuery.getCount(); tQuery.getCount(); Connection c = connectionPool.reserveConnection(); Assert.assertNotNull(c); connectionPool.releaseConnection(c); }
@Override public int getCount() throws SQLException { getLogger().log(Level.FINE, "Fetching count..."); StatementHelper sh = sqlGenerator.generateSelectQuery( getFullTableName(), filters, null, 0, 0, "COUNT(*)"); boolean shouldCloseTransaction = false; if (!isInTransaction()) { shouldCloseTransaction = true; beginTransaction(); } ResultSet r = null; int count = -1; try { r = executeQuery(sh); r.next(); count = r.getInt(1); } finally { try { if (r != null) { releaseConnection(null, r.getStatement(), r); } } finally { if (shouldCloseTransaction) { commit(); } } } return count; }
TableQuery extends AbstractTransactionalQuery implements
        QueryDelegate, QueryDelegate.RowIdChangeNotifier { @Override public int getCount() throws SQLException { getLogger().log(Level.FINE, "Fetching count..."); StatementHelper sh = sqlGenerator.generateSelectQuery( getFullTableName(), filters, null, 0, 0, "COUNT(*)"); boolean shouldCloseTransaction = false; if (!isInTransaction()) { shouldCloseTransaction = true; beginTransaction(); } ResultSet r = null; int count = -1; try { r = executeQuery(sh); r.next(); count = r.getInt(1); } finally { try { if (r != null) { releaseConnection(null, r.getStatement(), r); } } finally { if (shouldCloseTransaction) { commit(); } } } return count; } }
TableQuery extends AbstractTransactionalQuery implements
        QueryDelegate, QueryDelegate.RowIdChangeNotifier { @Override public int getCount() throws SQLException { getLogger().log(Level.FINE, "Fetching count..."); StatementHelper sh = sqlGenerator.generateSelectQuery( getFullTableName(), filters, null, 0, 0, "COUNT(*)"); boolean shouldCloseTransaction = false; if (!isInTransaction()) { shouldCloseTransaction = true; beginTransaction(); } ResultSet r = null; int count = -1; try { r = executeQuery(sh); r.next(); count = r.getInt(1); } finally { try { if (r != null) { releaseConnection(null, r.getStatement(), r); } } finally { if (shouldCloseTransaction) { commit(); } } } return count; } TableQuery(String tableName, JDBCConnectionPool connectionPool,
            SQLGenerator sqlGenerator);  TableQuery(String catalogName, String schemaName, String tableName,
            JDBCConnectionPool connectionPool, SQLGenerator sqlGenerator);  TableQuery(String tableName, JDBCConnectionPool connectionPool); protected  TableQuery(String catalogName, String schemaName,
            String tableName, JDBCConnectionPool connectionPool,
            SQLGenerator sqlGenerator, boolean escapeNames); }
TableQuery extends AbstractTransactionalQuery implements
        QueryDelegate, QueryDelegate.RowIdChangeNotifier { @Override public int getCount() throws SQLException { getLogger().log(Level.FINE, "Fetching count..."); StatementHelper sh = sqlGenerator.generateSelectQuery( getFullTableName(), filters, null, 0, 0, "COUNT(*)"); boolean shouldCloseTransaction = false; if (!isInTransaction()) { shouldCloseTransaction = true; beginTransaction(); } ResultSet r = null; int count = -1; try { r = executeQuery(sh); r.next(); count = r.getInt(1); } finally { try { if (r != null) { releaseConnection(null, r.getStatement(), r); } } finally { if (shouldCloseTransaction) { commit(); } } } return count; } TableQuery(String tableName, JDBCConnectionPool connectionPool,
            SQLGenerator sqlGenerator);  TableQuery(String catalogName, String schemaName, String tableName,
            JDBCConnectionPool connectionPool, SQLGenerator sqlGenerator);  TableQuery(String tableName, JDBCConnectionPool connectionPool); protected  TableQuery(String catalogName, String schemaName,
            String tableName, JDBCConnectionPool connectionPool,
            SQLGenerator sqlGenerator, boolean escapeNames); @Override int getCount(); @Override ResultSet getResults(int offset, int pagelength); @Override boolean implementationRespectsPagingLimits(); @Override int storeRow(RowItem row); RowId storeRowImmediately(RowItem row); @Override void setFilters(List<Filter> filters); @Override void setOrderBy(List<OrderBy> orderBys); @Override void beginTransaction(); @Override void commit(); @Override void rollback(); @Override List<String> getPrimaryKeyColumns(); String getVersionColumn(); void setVersionColumn(String column); String getTableName(); String getCatalogName(); String getSchemaName(); SQLGenerator getSqlGenerator(); @Override boolean removeRow(RowItem row); @Override boolean containsRowWithKey(Object... keys); @Override void addRowIdChangeListener(RowIdChangeListener listener); @Override void removeRowIdChangeListener(RowIdChangeListener listener); }
TableQuery extends AbstractTransactionalQuery implements
        QueryDelegate, QueryDelegate.RowIdChangeNotifier { @Override public int getCount() throws SQLException { getLogger().log(Level.FINE, "Fetching count..."); StatementHelper sh = sqlGenerator.generateSelectQuery( getFullTableName(), filters, null, 0, 0, "COUNT(*)"); boolean shouldCloseTransaction = false; if (!isInTransaction()) { shouldCloseTransaction = true; beginTransaction(); } ResultSet r = null; int count = -1; try { r = executeQuery(sh); r.next(); count = r.getInt(1); } finally { try { if (r != null) { releaseConnection(null, r.getStatement(), r); } } finally { if (shouldCloseTransaction) { commit(); } } } return count; } TableQuery(String tableName, JDBCConnectionPool connectionPool,
            SQLGenerator sqlGenerator);  TableQuery(String catalogName, String schemaName, String tableName,
            JDBCConnectionPool connectionPool, SQLGenerator sqlGenerator);  TableQuery(String tableName, JDBCConnectionPool connectionPool); protected  TableQuery(String catalogName, String schemaName,
            String tableName, JDBCConnectionPool connectionPool,
            SQLGenerator sqlGenerator, boolean escapeNames); @Override int getCount(); @Override ResultSet getResults(int offset, int pagelength); @Override boolean implementationRespectsPagingLimits(); @Override int storeRow(RowItem row); RowId storeRowImmediately(RowItem row); @Override void setFilters(List<Filter> filters); @Override void setOrderBy(List<OrderBy> orderBys); @Override void beginTransaction(); @Override void commit(); @Override void rollback(); @Override List<String> getPrimaryKeyColumns(); String getVersionColumn(); void setVersionColumn(String column); String getTableName(); String getCatalogName(); String getSchemaName(); SQLGenerator getSqlGenerator(); @Override boolean removeRow(RowItem row); @Override boolean containsRowWithKey(Object... keys); @Override void addRowIdChangeListener(RowIdChangeListener listener); @Override void removeRowIdChangeListener(RowIdChangeListener listener);  }