2 * Copyright 2000-2021 Vaadin Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
16 package com.vaadin.v7.data.util.sqlcontainer.query;
18 import java.io.Serializable;
19 import java.sql.Connection;
20 import java.sql.SQLException;
21 import java.util.List;
23 import com.vaadin.v7.data.Container.Filter;
24 import com.vaadin.v7.data.util.sqlcontainer.RowItem;
27 * @deprecated As of 8.0, no replacement available.
30 public interface FreeformQueryDelegate extends Serializable {
32 * Should return the SQL query string to be performed. This method is
33 * responsible for gluing together the select query from the filters and the
34 * order by conditions if these are supported.
37 * the first record (row) to fetch.
39 * the limit of records (rows) to fetch. 0 means all records
40 * starting from offset.
41 * @deprecated As of 6.7. Implement {@link FreeformStatementDelegate}
42 * instead of {@link FreeformQueryDelegate}
45 public String getQueryString(int offset, int limit)
46 throws UnsupportedOperationException;
49 * Generates and executes a query to determine the current row count from
50 * the DB. Row count will be fetched using filters that are currently set to
54 * @throws SQLException
55 * @deprecated As of 6.7. Implement {@link FreeformStatementDelegate}
56 * instead of {@link FreeformQueryDelegate}
59 public String getCountQuery() throws UnsupportedOperationException;
62 * Sets the filters to apply when performing the SQL query. These are
63 * translated into a WHERE clause. Default filtering mode will be used.
66 * The filters to apply.
67 * @throws UnsupportedOperationException
68 * if the implementation doesn't support filtering.
70 public void setFilters(List<Filter> filters)
71 throws UnsupportedOperationException;
74 * Sets the order in which to retrieve rows from the database. The result
75 * can be ordered by zero or more columns and each column can be in
76 * ascending or descending order. These are translated into an ORDER BY
77 * clause in the SQL query.
80 * A list of the OrderBy conditions.
81 * @throws UnsupportedOperationException
82 * if the implementation doesn't support ordering.
84 public void setOrderBy(List<OrderBy> orderBys)
85 throws UnsupportedOperationException;
88 * Stores a row in the database. The implementation of this interface
89 * decides how to identify whether to store a new row or update an existing
93 * the JDBC connection to use
95 * RowItem to be stored or updated.
96 * @throws UnsupportedOperationException
97 * if the implementation is read only.
98 * @throws SQLException
100 public int storeRow(Connection conn, RowItem row)
101 throws UnsupportedOperationException, SQLException;
104 * Removes the given RowItem from the database.
107 * the JDBC connection to use
109 * RowItem to be removed
110 * @return true on success
111 * @throws UnsupportedOperationException
112 * @throws SQLException
114 public boolean removeRow(Connection conn, RowItem row)
115 throws UnsupportedOperationException, SQLException;
118 * Generates an SQL Query string that allows the user of the FreeformQuery
119 * class to customize the query string used by the
120 * FreeformQuery.containsRowWithKeys() method. This is useful for cases when
121 * the logic in the containsRowWithKeys method is not enough to support more
122 * complex free form queries.
125 * the values of the primary keys
126 * @throws UnsupportedOperationException
127 * to use the default logic in FreeformQuery
128 * @deprecated As of 6.7. Implement {@link FreeformStatementDelegate}
129 * instead of {@link FreeformQueryDelegate}
132 public String getContainsRowQueryString(Object... keys)
133 throws UnsupportedOperationException;