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;
18 import com.vaadin.v7.data.util.sqlcontainer.query.generator.StatementHelper;
21 * FreeformStatementDelegate is an extension to FreeformQueryDelegate that
22 * provides definitions for methods that produce StatementHelper objects instead
23 * of basic query strings. This allows the FreeformQuery query delegate to use
24 * PreparedStatements instead of regular Statement when accessing the database.
26 * Due to the injection protection and other benefits of prepared statements, it
27 * is advisable to implement this interface instead of the FreeformQueryDelegate
30 * @deprecated As of 8.0, no replacement available.
33 public interface FreeformStatementDelegate extends FreeformQueryDelegate {
35 * Should return a new instance of StatementHelper that contains the query
36 * string and parameter values required to create a PreparedStatement. This
37 * method is responsible for gluing together the select query from the
38 * filters and the order by conditions if these are supported.
41 * the first record (row) to fetch.
43 * the limit of records (rows) to fetch. 0 means all records
44 * starting from offset.
46 public StatementHelper getQueryStatement(int offset, int limit)
47 throws UnsupportedOperationException;
50 * Should return a new instance of StatementHelper that contains the query
51 * string and parameter values required to create a PreparedStatement that
52 * will fetch the row count from the DB. Row count should be fetched using
53 * filters that are currently set to the QueryDelegate.
55 public StatementHelper getCountStatement()
56 throws UnsupportedOperationException;
59 * Should return a new instance of StatementHelper that contains the query
60 * string and parameter values required to create a PreparedStatement used
61 * by the FreeformQuery.containsRowWithKeys() method. This is useful for
62 * cases when the default logic in said method is not enough to support more
63 * complex free form queries.
66 * the values of the primary keys
67 * @throws UnsupportedOperationException
68 * to use the default logic in FreeformQuery
70 public StatementHelper getContainsRowQueryStatement(Object... keys)
71 throws UnsupportedOperationException;