Examples of FreeformQueryDelegate


Examples of com.vaadin.data.util.sqlcontainer.query.FreeformQueryDelegate

    @SuppressWarnings("unchecked")
    @Test
    public void commit_freeformRemovedItem_shouldBeRemovedFromDB()
            throws SQLException {
        FreeformQueryDelegate delegate = EasyMock
                .createMock(FreeformQueryDelegate.class);
        EasyMock.expect(
                delegate.removeRow(EasyMock.isA(Connection.class),
                        EasyMock.isA(RowItem.class)))
                .andAnswer(new IAnswer<Boolean>() {
                    @Override
                    public Boolean answer() throws Throwable {
                        Connection conn = (Connection) EasyMock
                                .getCurrentArguments()[0];
                        RowItem item = (RowItem) EasyMock.getCurrentArguments()[1];
                        Statement statement = conn.createStatement();
                        statement
                                .executeUpdate("DELETE FROM people WHERE \"ID\"="
                                        + item.getItemProperty("ID").getValue());
                        statement.close();
                        return true;
                    }
                }).anyTimes();
        EasyMock.expect(
                delegate.getQueryString(EasyMock.anyInt(), EasyMock.anyInt()))
                .andAnswer(new IAnswer<String>() {
                    @Override
                    public String answer() throws Throwable {
                        Object[] args = EasyMock.getCurrentArguments();
                        int offset = (Integer) (args[0]);
                        int limit = (Integer) (args[1]);
                        if (SQLTestsConstants.db == DB.MSSQL) {
                            int start = offset + 1;
                            int end = offset + limit + 1;
                            String q = "SELECT * FROM (SELECT row_number() OVER"
                                    + " ( ORDER BY \"ID\" ASC) AS rownum, * FROM people)"
                                    + " AS a WHERE a.rownum BETWEEN "
                                    + start
                                    + " AND " + end;
                            return q;
                        } else if (SQLTestsConstants.db == DB.ORACLE) {
                            int start = offset + 1;
                            int end = offset + limit + 1;
                            String q = "SELECT * FROM (SELECT x.*, ROWNUM AS r FROM"
                                    + " (SELECT * FROM people ORDER BY \"ID\" ASC) x) "
                                    + " WHERE r BETWEEN "
                                    + start
                                    + " AND "
                                    + end;
                            return q;
                        } else {
                            return "SELECT * FROM people LIMIT " + limit
                                    + " OFFSET " + offset;
                        }
                    }
                }).anyTimes();
        delegate.setFilters(null);
        EasyMock.expectLastCall().anyTimes();
        delegate.setFilters(EasyMock.isA(List.class));
        EasyMock.expectLastCall().anyTimes();
        delegate.setOrderBy(null);
        EasyMock.expectLastCall().anyTimes();
        delegate.setOrderBy(EasyMock.isA(List.class));
        EasyMock.expectLastCall().anyTimes();
        EasyMock.expect(delegate.getCountQuery())
                .andThrow(new UnsupportedOperationException()).anyTimes();

        FreeformQuery query = new FreeformQuery("SELECT * FROM people",
                connectionPool, "ID");
        query.setDelegate(delegate);
View Full Code Here

Examples of com.vaadin.data.util.sqlcontainer.query.FreeformQueryDelegate

    @SuppressWarnings("unchecked")
    @Test
    public void commit_freeformLastItemUpdated_shouldUpdateRowInDB()
            throws SQLException {
        FreeformQueryDelegate delegate = EasyMock
                .createMock(FreeformQueryDelegate.class);
        EasyMock.expect(
                delegate.storeRow(EasyMock.isA(Connection.class),
                        EasyMock.isA(RowItem.class)))
                .andAnswer(new IAnswer<Integer>() {
                    @Override
                    public Integer answer() throws Throwable {
                        Connection conn = (Connection) EasyMock
                                .getCurrentArguments()[0];
                        RowItem item = (RowItem) EasyMock.getCurrentArguments()[1];
                        Statement statement = conn.createStatement();
                        statement.executeUpdate("UPDATE people SET \"NAME\"='"
                                + item.getItemProperty("NAME").getValue()
                                + "' WHERE \"ID\"="
                                + item.getItemProperty("ID").getValue());
                        statement.close();
                        conn.commit();
                        connectionPool.releaseConnection(conn);
                        return 1;
                    }
                }).anyTimes();
        EasyMock.expect(
                delegate.getQueryString(EasyMock.anyInt(), EasyMock.anyInt()))
                .andAnswer(new IAnswer<String>() {
                    @Override
                    public String answer() throws Throwable {
                        Object[] args = EasyMock.getCurrentArguments();
                        int offset = (Integer) (args[0]);
                        int limit = (Integer) (args[1]);
                        if (SQLTestsConstants.db == DB.MSSQL) {
                            int start = offset + 1;
                            int end = offset + limit + 1;
                            String q = "SELECT * FROM (SELECT row_number() OVER"
                                    + " ( ORDER BY \"ID\" ASC) AS rownum, * FROM people)"
                                    + " AS a WHERE a.rownum BETWEEN "
                                    + start
                                    + " AND " + end;
                            return q;
                        } else if (SQLTestsConstants.db == DB.ORACLE) {
                            int start = offset + 1;
                            int end = offset + limit + 1;
                            String q = "SELECT * FROM (SELECT x.*, ROWNUM AS r FROM"
                                    + " (SELECT * FROM people ORDER BY \"ID\" ASC) x) "
                                    + " WHERE r BETWEEN "
                                    + start
                                    + " AND "
                                    + end;
                            return q;
                        } else {
                            return "SELECT * FROM people LIMIT " + limit
                                    + " OFFSET " + offset;
                        }
                    }
                }).anyTimes();
        delegate.setFilters(null);
        EasyMock.expectLastCall().anyTimes();
        delegate.setFilters(EasyMock.isA(List.class));
        EasyMock.expectLastCall().anyTimes();
        delegate.setOrderBy(null);
        EasyMock.expectLastCall().anyTimes();
        delegate.setOrderBy(EasyMock.isA(List.class));
        EasyMock.expectLastCall().anyTimes();
        EasyMock.expect(delegate.getCountQuery())
                .andThrow(new UnsupportedOperationException()).anyTimes();

        FreeformQuery query = new FreeformQuery("SELECT * FROM people",
                connectionPool, "ID");
        query.setDelegate(delegate);
View Full Code Here

Examples of com.vaadin.data.util.sqlcontainer.query.FreeformQueryDelegate

    @SuppressWarnings("unchecked")
    @Test
    public void addOrderBy_freeform_shouldReorderResults() throws SQLException {
        FreeformQuery query = new FreeformQuery("SELECT * FROM people",
                connectionPool, "ID");
        FreeformQueryDelegate delegate = EasyMock
                .createMock(FreeformQueryDelegate.class);
        final ArrayList<OrderBy> orderBys = new ArrayList<OrderBy>();
        delegate.setFilters(null);
        EasyMock.expectLastCall().anyTimes();
        delegate.setFilters(EasyMock.isA(List.class));
        EasyMock.expectLastCall().anyTimes();
        delegate.setOrderBy(null);
        EasyMock.expectLastCall().anyTimes();
        delegate.setOrderBy(EasyMock.isA(List.class));
        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
            @Override
            public Object answer() throws Throwable {
                List<OrderBy> orders = (List<OrderBy>) EasyMock
                        .getCurrentArguments()[0];
                orderBys.clear();
                orderBys.addAll(orders);
                return null;
            }
        }).anyTimes();
        EasyMock.expect(
                delegate.getQueryString(EasyMock.anyInt(), EasyMock.anyInt()))
                .andAnswer(new IAnswer<String>() {
                    @Override
                    public String answer() throws Throwable {
                        Object[] args = EasyMock.getCurrentArguments();
                        int offset = (Integer) (args[0]);
                        int limit = (Integer) (args[1]);
                        if (SQLTestsConstants.db == DB.MSSQL) {
                            SQLGenerator gen = new MSSQLGenerator();
                            if (orderBys == null || orderBys.isEmpty()) {
                                List<OrderBy> ob = new ArrayList<OrderBy>();
                                ob.add(new OrderBy("ID", true));
                                return gen.generateSelectQuery("people", null,
                                        ob, offset, limit, null)
                                        .getQueryString();
                            } else {
                                return gen.generateSelectQuery("people", null,
                                        orderBys, offset, limit, null)
                                        .getQueryString();
                            }
                        } else if (SQLTestsConstants.db == DB.ORACLE) {
                            SQLGenerator gen = new OracleGenerator();
                            if (orderBys == null || orderBys.isEmpty()) {
                                List<OrderBy> ob = new ArrayList<OrderBy>();
                                ob.add(new OrderBy("ID", true));
                                return gen.generateSelectQuery("people", null,
                                        ob, offset, limit, null)
                                        .getQueryString();
                            } else {
                                return gen.generateSelectQuery("people", null,
                                        orderBys, offset, limit, null)
                                        .getQueryString();
                            }
                        } else {
                            StringBuffer query = new StringBuffer(
                                    "SELECT * FROM people");
                            if (!orderBys.isEmpty()) {
                                query.append(" ORDER BY ");
                                for (OrderBy orderBy : orderBys) {
                                    query.append("\"" + orderBy.getColumn()
                                            + "\"");
                                    if (orderBy.isAscending()) {
                                        query.append(" ASC");
                                    } else {
                                        query.append(" DESC");
                                    }
                                }
                            }
                            query.append(" LIMIT ").append(limit)
                                    .append(" OFFSET ").append(offset);
                            return query.toString();
                        }
                    }
                }).anyTimes();
        EasyMock.expect(delegate.getCountQuery())
                .andThrow(new UnsupportedOperationException()).anyTimes();

        EasyMock.replay(delegate);
        query.setDelegate(delegate);
        SQLContainer container = new SQLContainer(query);
View Full Code Here

Examples of com.vaadin.data.util.sqlcontainer.query.FreeformQueryDelegate

    @SuppressWarnings("unchecked")
    @Test
    public void sort_freeform_sortsByName() throws SQLException {
        FreeformQuery query = new FreeformQuery("SELECT * FROM people",
                connectionPool, "ID");
        FreeformQueryDelegate delegate = EasyMock
                .createMock(FreeformQueryDelegate.class);
        final ArrayList<OrderBy> orderBys = new ArrayList<OrderBy>();
        delegate.setFilters(null);
        EasyMock.expectLastCall().anyTimes();
        delegate.setFilters(EasyMock.isA(List.class));
        EasyMock.expectLastCall().anyTimes();
        delegate.setOrderBy(null);
        EasyMock.expectLastCall().anyTimes();
        delegate.setOrderBy(EasyMock.isA(List.class));
        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
            @Override
            public Object answer() throws Throwable {
                List<OrderBy> orders = (List<OrderBy>) EasyMock
                        .getCurrentArguments()[0];
                orderBys.clear();
                orderBys.addAll(orders);
                return null;
            }
        }).anyTimes();
        EasyMock.expect(
                delegate.getQueryString(EasyMock.anyInt(), EasyMock.anyInt()))
                .andAnswer(new IAnswer<String>() {
                    @Override
                    public String answer() throws Throwable {
                        Object[] args = EasyMock.getCurrentArguments();
                        int offset = (Integer) (args[0]);
                        int limit = (Integer) (args[1]);
                        if (SQLTestsConstants.db == DB.MSSQL) {
                            SQLGenerator gen = new MSSQLGenerator();
                            if (orderBys == null || orderBys.isEmpty()) {
                                List<OrderBy> ob = new ArrayList<OrderBy>();
                                ob.add(new OrderBy("ID", true));
                                return gen.generateSelectQuery("people", null,
                                        ob, offset, limit, null)
                                        .getQueryString();
                            } else {
                                return gen.generateSelectQuery("people", null,
                                        orderBys, offset, limit, null)
                                        .getQueryString();
                            }
                        } else if (SQLTestsConstants.db == DB.ORACLE) {
                            SQLGenerator gen = new OracleGenerator();
                            if (orderBys == null || orderBys.isEmpty()) {
                                List<OrderBy> ob = new ArrayList<OrderBy>();
                                ob.add(new OrderBy("ID", true));
                                return gen.generateSelectQuery("people", null,
                                        ob, offset, limit, null)
                                        .getQueryString();
                            } else {
                                return gen.generateSelectQuery("people", null,
                                        orderBys, offset, limit, null)
                                        .getQueryString();
                            }
                        } else {
                            StringBuffer query = new StringBuffer(
                                    "SELECT * FROM people");
                            if (!orderBys.isEmpty()) {
                                query.append(" ORDER BY ");
                                for (OrderBy orderBy : orderBys) {
                                    query.append("\"" + orderBy.getColumn()
                                            + "\"");
                                    if (orderBy.isAscending()) {
                                        query.append(" ASC");
                                    } else {
                                        query.append(" DESC");
                                    }
                                }
                            }
                            query.append(" LIMIT ").append(limit)
                                    .append(" OFFSET ").append(offset);
                            return query.toString();
                        }
                    }
                }).anyTimes();
        EasyMock.expect(delegate.getCountQuery())
                .andThrow(new UnsupportedOperationException()).anyTimes();
        EasyMock.replay(delegate);

        query.setDelegate(delegate);
        SQLContainer container = new SQLContainer(query);
View Full Code Here

Examples of com.vaadin.data.util.sqlcontainer.query.FreeformQueryDelegate

    @Test
    public void sort_freeformBufferedItems_sortsBufferedItemsLastInOrderAdded()
            throws SQLException {
        FreeformQuery query = new FreeformQuery("SELECT * FROM people",
                connectionPool, "ID");
        FreeformQueryDelegate delegate = EasyMock
                .createMock(FreeformQueryDelegate.class);
        final ArrayList<OrderBy> orderBys = new ArrayList<OrderBy>();
        delegate.setFilters(null);
        EasyMock.expectLastCall().anyTimes();
        delegate.setFilters(EasyMock.isA(List.class));
        EasyMock.expectLastCall().anyTimes();
        delegate.setOrderBy(null);
        EasyMock.expectLastCall().anyTimes();
        delegate.setOrderBy(EasyMock.isA(List.class));
        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
            @Override
            public Object answer() throws Throwable {
                List<OrderBy> orders = (List<OrderBy>) EasyMock
                        .getCurrentArguments()[0];
                orderBys.clear();
                orderBys.addAll(orders);
                return null;
            }
        }).anyTimes();
        EasyMock.expect(
                delegate.getQueryString(EasyMock.anyInt(), EasyMock.anyInt()))
                .andAnswer(new IAnswer<String>() {
                    @Override
                    public String answer() throws Throwable {
                        Object[] args = EasyMock.getCurrentArguments();
                        int offset = (Integer) (args[0]);
                        int limit = (Integer) (args[1]);
                        if (SQLTestsConstants.db == DB.MSSQL) {
                            SQLGenerator gen = new MSSQLGenerator();
                            if (orderBys == null || orderBys.isEmpty()) {
                                List<OrderBy> ob = new ArrayList<OrderBy>();
                                ob.add(new OrderBy("ID", true));
                                return gen.generateSelectQuery("people", null,
                                        ob, offset, limit, null)
                                        .getQueryString();
                            } else {
                                return gen.generateSelectQuery("people", null,
                                        orderBys, offset, limit, null)
                                        .getQueryString();
                            }
                        } else if (SQLTestsConstants.db == DB.ORACLE) {
                            SQLGenerator gen = new OracleGenerator();
                            if (orderBys == null || orderBys.isEmpty()) {
                                List<OrderBy> ob = new ArrayList<OrderBy>();
                                ob.add(new OrderBy("ID", true));
                                return gen.generateSelectQuery("people", null,
                                        ob, offset, limit, null)
                                        .getQueryString();
                            } else {
                                return gen.generateSelectQuery("people", null,
                                        orderBys, offset, limit, null)
                                        .getQueryString();
                            }
                        } else {
                            StringBuffer query = new StringBuffer(
                                    "SELECT * FROM people");
                            if (!orderBys.isEmpty()) {
                                query.append(" ORDER BY ");
                                for (OrderBy orderBy : orderBys) {
                                    query.append("\"" + orderBy.getColumn()
                                            + "\"");
                                    if (orderBy.isAscending()) {
                                        query.append(" ASC");
                                    } else {
                                        query.append(" DESC");
                                    }
                                }
                            }
                            query.append(" LIMIT ").append(limit)
                                    .append(" OFFSET ").append(offset);
                            return query.toString();
                        }
                    }
                }).anyTimes();
        EasyMock.expect(delegate.getCountQuery())
                .andThrow(new UnsupportedOperationException()).anyTimes();
        EasyMock.replay(delegate);

        query.setDelegate(delegate);
        SQLContainer container = new SQLContainer(query);
View Full Code Here

Examples of com.vaadin.data.util.sqlcontainer.query.FreeformQueryDelegate

    public void getIdByIndex_freeformWithPaging5000rowsIndex1337_returnsRowId1337()
            throws SQLException {
        DataGenerator.addFiveThousandPeople(connectionPool);
        FreeformQuery query = new FreeformQuery("SELECT * FROM people",
                connectionPool, "ID");
        FreeformQueryDelegate delegate = EasyMock
                .createMock(FreeformQueryDelegate.class);
        EasyMock.expect(
                delegate.getQueryString(EasyMock.anyInt(), EasyMock.anyInt()))
                .andAnswer(new IAnswer<String>() {
                    @Override
                    public String answer() throws Throwable {
                        Object[] args = EasyMock.getCurrentArguments();
                        int offset = (Integer) (args[0]);
                        int limit = (Integer) (args[1]);
                        if (SQLTestsConstants.db == DB.MSSQL) {
                            int start = offset + 1;
                            int end = offset + limit + 1;
                            String q = "SELECT * FROM (SELECT row_number() OVER"
                                    + " ( ORDER BY \"ID\" ASC) AS rownum, * FROM people)"
                                    + " AS a WHERE a.rownum BETWEEN "
                                    + start
                                    + " AND " + end;
                            return q;
                        } else if (SQLTestsConstants.db == DB.ORACLE) {
                            int start = offset + 1;
                            int end = offset + limit + 1;
                            String q = "SELECT * FROM (SELECT x.*, ROWNUM AS r FROM"
                                    + " (SELECT * FROM people ORDER BY \"ID\" ASC) x) "
                                    + " WHERE r BETWEEN "
                                    + start
                                    + " AND "
                                    + end;
                            return q;
                        } else {
                            return "SELECT * FROM people LIMIT " + limit
                                    + " OFFSET " + offset;
                        }
                    }
                }).anyTimes();
        delegate.setFilters(null);
        EasyMock.expectLastCall().anyTimes();
        delegate.setFilters(EasyMock.isA(List.class));
        EasyMock.expectLastCall().anyTimes();
        delegate.setOrderBy(null);
        EasyMock.expectLastCall().anyTimes();
        delegate.setOrderBy(EasyMock.isA(List.class));
        EasyMock.expectLastCall().anyTimes();
        EasyMock.expect(delegate.getCountQuery())
                .andThrow(new UnsupportedOperationException()).anyTimes();
        EasyMock.replay(delegate);
        query.setDelegate(delegate);
        SQLContainer container = new SQLContainer(query);
        Object itemId = container.getIdByIndex(1337);
View Full Code Here

Examples of com.vaadin.data.util.sqlcontainer.query.FreeformQueryDelegate

    @SuppressWarnings("unchecked")
    @Test
    public void commit_freeformAddedItem_shouldBeWrittenToDB()
            throws SQLException {
        FreeformQueryDelegate delegate = EasyMock
                .createMock(FreeformQueryDelegate.class);
        EasyMock.expect(
                delegate.storeRow(EasyMock.isA(Connection.class),
                        EasyMock.isA(RowItem.class)))
                .andAnswer(new IAnswer<Integer>() {
                    @Override
                    public Integer answer() throws Throwable {
                        Connection conn = (Connection) EasyMock
                                .getCurrentArguments()[0];
                        RowItem item = (RowItem) EasyMock.getCurrentArguments()[1];
                        Statement statement = conn.createStatement();
                        if (SQLTestsConstants.db == DB.MSSQL) {
                            statement
                                    .executeUpdate("insert into people values('"
                                            + item.getItemProperty("NAME")
                                                    .getValue()
                                            + "', '"
                                            + item.getItemProperty("AGE")
                                                    .getValue() + "')");
                        } else {
                            statement
                                    .executeUpdate("insert into people values(default, '"
                                            + item.getItemProperty("NAME")
                                                    .getValue()
                                            + "', '"
                                            + item.getItemProperty("AGE")
                                                    .getValue() + "')");
                        }
                        statement.close();
                        conn.commit();
                        connectionPool.releaseConnection(conn);
                        return 1;
                    }
                }).anyTimes();
        EasyMock.expect(
                delegate.getQueryString(EasyMock.anyInt(), EasyMock.anyInt()))
                .andAnswer(new IAnswer<String>() {
                    @Override
                    public String answer() throws Throwable {
                        Object[] args = EasyMock.getCurrentArguments();
                        int offset = (Integer) (args[0]);
                        int limit = (Integer) (args[1]);
                        if (SQLTestsConstants.db == DB.MSSQL) {
                            int start = offset + 1;
                            int end = offset + limit + 1;
                            String q = "SELECT * FROM (SELECT row_number() OVER"
                                    + " ( ORDER BY \"ID\" ASC) AS rownum, * FROM people)"
                                    + " AS a WHERE a.rownum BETWEEN "
                                    + start
                                    + " AND " + end;
                            return q;
                        } else if (SQLTestsConstants.db == DB.ORACLE) {
                            int start = offset + 1;
                            int end = offset + limit + 1;
                            String q = "SELECT * FROM (SELECT x.*, ROWNUM AS r FROM"
                                    + " (SELECT * FROM people ORDER BY \"ID\" ASC) x) "
                                    + " WHERE r BETWEEN "
                                    + start
                                    + " AND "
                                    + end;
                            return q;
                        } else {
                            return "SELECT * FROM people LIMIT " + limit
                                    + " OFFSET " + offset;
                        }
                    }
                }).anyTimes();
        delegate.setFilters(null);
        EasyMock.expectLastCall().anyTimes();
        delegate.setFilters(EasyMock.isA(List.class));
        EasyMock.expectLastCall().anyTimes();
        delegate.setOrderBy(null);
        EasyMock.expectLastCall().anyTimes();
        delegate.setOrderBy(EasyMock.isA(List.class));
        EasyMock.expectLastCall().anyTimes();
        EasyMock.expect(delegate.getCountQuery())
                .andThrow(new UnsupportedOperationException()).anyTimes();

        FreeformQuery query = new FreeformQuery("SELECT * FROM people",
                connectionPool, "ID");
        query.setDelegate(delegate);
View Full Code Here

Examples of com.vaadin.data.util.sqlcontainer.query.FreeformQueryDelegate

    @SuppressWarnings("unchecked")
    @Test
    public void commit_freeformTwoAddedItems_shouldBeWrittenToDB()
            throws SQLException {
        FreeformQueryDelegate delegate = EasyMock
                .createMock(FreeformQueryDelegate.class);
        EasyMock.expect(
                delegate.storeRow(EasyMock.isA(Connection.class),
                        EasyMock.isA(RowItem.class)))
                .andAnswer(new IAnswer<Integer>() {
                    @Override
                    public Integer answer() throws Throwable {
                        Connection conn = (Connection) EasyMock
                                .getCurrentArguments()[0];
                        RowItem item = (RowItem) EasyMock.getCurrentArguments()[1];
                        Statement statement = conn.createStatement();
                        if (SQLTestsConstants.db == DB.MSSQL) {
                            statement
                                    .executeUpdate("insert into people values('"
                                            + item.getItemProperty("NAME")
                                                    .getValue()
                                            + "', '"
                                            + item.getItemProperty("AGE")
                                                    .getValue() + "')");
                        } else {
                            statement
                                    .executeUpdate("insert into people values(default, '"
                                            + item.getItemProperty("NAME")
                                                    .getValue()
                                            + "', '"
                                            + item.getItemProperty("AGE")
                                                    .getValue() + "')");
                        }
                        statement.close();
                        conn.commit();
                        connectionPool.releaseConnection(conn);
                        return 1;
                    }
                }).anyTimes();
        EasyMock.expect(
                delegate.getQueryString(EasyMock.anyInt(), EasyMock.anyInt()))
                .andAnswer(new IAnswer<String>() {
                    @Override
                    public String answer() throws Throwable {
                        Object[] args = EasyMock.getCurrentArguments();
                        int offset = (Integer) (args[0]);
                        int limit = (Integer) (args[1]);
                        if (SQLTestsConstants.db == DB.MSSQL) {
                            int start = offset + 1;
                            int end = offset + limit + 1;
                            String q = "SELECT * FROM (SELECT row_number() OVER"
                                    + " ( ORDER BY \"ID\" ASC) AS rownum, * FROM people)"
                                    + " AS a WHERE a.rownum BETWEEN "
                                    + start
                                    + " AND " + end;
                            return q;
                        } else if (SQLTestsConstants.db == DB.ORACLE) {
                            int start = offset + 1;
                            int end = offset + limit + 1;
                            String q = "SELECT * FROM (SELECT x.*, ROWNUM AS r FROM"
                                    + " (SELECT * FROM people ORDER BY \"ID\" ASC) x) "
                                    + " WHERE r BETWEEN "
                                    + start
                                    + " AND "
                                    + end;
                            return q;
                        } else {
                            return "SELECT * FROM people LIMIT " + limit
                                    + " OFFSET " + offset;
                        }
                    }
                }).anyTimes();
        delegate.setFilters(null);
        EasyMock.expectLastCall().anyTimes();
        delegate.setFilters(EasyMock.isA(List.class));
        EasyMock.expectLastCall().anyTimes();
        delegate.setOrderBy(null);
        EasyMock.expectLastCall().anyTimes();
        delegate.setOrderBy(EasyMock.isA(List.class));
        EasyMock.expectLastCall().anyTimes();
        EasyMock.expect(delegate.getCountQuery())
                .andThrow(new UnsupportedOperationException()).anyTimes();

        FreeformQuery query = new FreeformQuery("SELECT * FROM people",
                connectionPool, "ID");
        query.setDelegate(delegate);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.