2 * Copyright 2000-2018 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.generator;
18 import java.io.Serializable;
19 import java.util.List;
21 import com.vaadin.v7.data.Container.Filter;
22 import com.vaadin.v7.data.util.sqlcontainer.RowItem;
23 import com.vaadin.v7.data.util.sqlcontainer.query.OrderBy;
26 * The SQLGenerator interface is meant to be implemented for each different SQL
27 * syntax that is to be supported. By default there are implementations for
28 * HSQLDB, MySQL, PostgreSQL, MSSQL and Oracle syntaxes.
30 * @author Jonatan Kronqvist / Vaadin Ltd
32 * @deprecated As of 8.0, no replacement available.
35 public interface SQLGenerator extends Serializable {
37 * Generates a SELECT query with the provided parameters. Uses default
38 * filtering mode (INCLUSIVE).
41 * Name of the table queried
43 * The filters, converted into a WHERE clause
45 * The the ordering conditions, converted into an ORDER BY clause
47 * The offset of the first row to be included
49 * The number of rows to be returned when the query executes
51 * String containing what to select, e.g. "*", "COUNT(*)"
52 * @return StatementHelper instance containing the query string for a
53 * PreparedStatement and the values required for the parameters
55 public StatementHelper generateSelectQuery(String tableName,
56 List<Filter> filters, List<OrderBy> orderBys, int offset,
57 int pagelength, String toSelect);
60 * Generates an UPDATE query with the provided parameters.
63 * Name of the table queried
65 * RowItem containing the updated values update.
66 * @return StatementHelper instance containing the query string for a
67 * PreparedStatement and the values required for the parameters
69 public StatementHelper generateUpdateQuery(String tableName, RowItem item);
72 * Generates an INSERT query for inserting a new row with the provided
76 * Name of the table queried
78 * New RowItem to be inserted into the database.
79 * @return StatementHelper instance containing the query string for a
80 * PreparedStatement and the values required for the parameters
82 public StatementHelper generateInsertQuery(String tableName, RowItem item);
85 * Generates a DELETE query for deleting data related to the given RowItem
89 * Name of the table queried
90 * @param primaryKeyColumns
91 * the names of the columns holding the primary key. Usually just
92 * one column, but might be several.
93 * @param versionColumn
94 * the column containing the version number of the row, null if
95 * versioning (optimistic locking) not enabled.
97 * Item to be deleted from the database
98 * @return StatementHelper instance containing the query string for a
99 * PreparedStatement and the values required for the parameters
101 public StatementHelper generateDeleteQuery(String tableName,
102 List<String> primaryKeyColumns, String versionColumn, RowItem item);