class PhasingPollTable extends EntityDbTable<PhasingPoll> {

    public DbIterator<Transaction> getHoldingPhasedTransactions(long holdingId, VoteWeighting.VotingModel votingModel,
                                                                long accountId, boolean withoutWhitelist, int from, int to, int height) throws SQLException {

        Connection con = null;
        try {
            con = getDatabaseManager().getDataSource().getConnection();
            PreparedStatement pstmt = con.prepareStatement("SELECT transaction.* " +
                "FROM transaction, phasing_poll " +
                "WHERE phasing_poll.holding_id = ? " +
                "AND phasing_poll.voting_model = ? " +
                "AND phasing_poll.id = transaction.id " +
                "AND phasing_poll.finish_height > ? " +
                (accountId != 0 ? "AND phasing_poll.account_id = ? " : "") +
                (withoutWhitelist ? "AND phasing_poll.whitelist_size = 0 " : "") +
                "ORDER BY transaction.height DESC, transaction.transaction_index DESC " +
                DbUtils.limitsClause(from, to));
            int i = 0;
            pstmt.setLong(++i, holdingId);
            pstmt.setByte(++i, votingModel.getCode());
            pstmt.setInt(++i, height);
            if (accountId != 0) {
                pstmt.setLong(++i, accountId);
            }
            DbUtils.setLimits(++i, pstmt, from, to);

            return blockchain.getTransactions(con, pstmt);
        } catch (SQLException e) {
            DbUtils.close(con);
            throw e;
        }
    }

    @Inject public  PhasingPollTable(Blockchain blockchain);

}