Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

QueryDelegate.java 8.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  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
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  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
  14. * the License.
  15. */
  16. package com.vaadin.v7.data.util.sqlcontainer.query;
  17. import java.io.Serializable;
  18. import java.sql.ResultSet;
  19. import java.sql.SQLException;
  20. import java.util.List;
  21. import com.vaadin.v7.data.Container.Filter;
  22. import com.vaadin.v7.data.util.sqlcontainer.RowId;
  23. import com.vaadin.v7.data.util.sqlcontainer.RowItem;
  24. /**
  25. * @deprecated As of 8.0, no replacement available.
  26. */
  27. @Deprecated
  28. public interface QueryDelegate extends Serializable {
  29. /**
  30. * Generates and executes a query to determine the current row count from
  31. * the DB. Row count will be fetched using filters that are currently set to
  32. * the QueryDelegate.
  33. *
  34. * @return row count
  35. * @throws SQLException
  36. */
  37. public int getCount() throws SQLException;
  38. /**
  39. * Executes a paged SQL query and returns the ResultSet. The query is
  40. * defined through implementations of this QueryDelegate interface.
  41. *
  42. * @param offset
  43. * the first item of the page to load
  44. * @param pagelength
  45. * the length of the page to load
  46. * @return a ResultSet containing the rows of the page
  47. * @throws SQLException
  48. * if the database access fails.
  49. */
  50. public ResultSet getResults(int offset, int pagelength) throws SQLException;
  51. /**
  52. * Allows the SQLContainer implementation to check whether the QueryDelegate
  53. * implementation implements paging in the getResults method.
  54. *
  55. * @see QueryDelegate#getResults(int, int)
  56. *
  57. * @return true if the delegate implements paging
  58. */
  59. public boolean implementationRespectsPagingLimits();
  60. /**
  61. * Sets the filters to apply when performing the SQL query. These are
  62. * translated into a WHERE clause. Default filtering mode will be used.
  63. *
  64. * @param filters
  65. * The filters to apply.
  66. * @throws UnsupportedOperationException
  67. * if the implementation doesn't support filtering.
  68. */
  69. public void setFilters(List<Filter> filters)
  70. throws UnsupportedOperationException;
  71. /**
  72. * Sets the order in which to retrieve rows from the database. The result
  73. * can be ordered by zero or more columns and each column can be in
  74. * ascending or descending order. These are translated into an ORDER BY
  75. * clause in the SQL query.
  76. *
  77. * @param orderBys
  78. * A list of the OrderBy conditions.
  79. * @throws UnsupportedOperationException
  80. * if the implementation doesn't support ordering.
  81. */
  82. public void setOrderBy(List<OrderBy> orderBys)
  83. throws UnsupportedOperationException;
  84. /**
  85. * Stores a row in the database. The implementation of this interface
  86. * decides how to identify whether to store a new row or update an existing
  87. * one.
  88. *
  89. * @param columnToValueMap
  90. * A map containing the values for all columns to be stored or
  91. * updated.
  92. * @return the number of affected rows in the database table
  93. * @throws UnsupportedOperationException
  94. * if the implementation is read only.
  95. */
  96. public int storeRow(RowItem row)
  97. throws UnsupportedOperationException, SQLException;
  98. /**
  99. * Removes the given RowItem from the database.
  100. *
  101. * @param row
  102. * RowItem to be removed
  103. * @return true on success
  104. * @throws UnsupportedOperationException
  105. * @throws SQLException
  106. */
  107. public boolean removeRow(RowItem row)
  108. throws UnsupportedOperationException, SQLException;
  109. /**
  110. * Starts a new database transaction. Used when storing multiple changes.
  111. *
  112. * Note that if a transaction is already open, it will be rolled back when a
  113. * new transaction is started.
  114. *
  115. * @throws SQLException
  116. * if the database access fails.
  117. */
  118. public void beginTransaction() throws SQLException;
  119. /**
  120. * Commits a transaction. If a transaction is not open nothing should
  121. * happen.
  122. *
  123. * @throws SQLException
  124. * if the database access fails.
  125. */
  126. public void commit() throws SQLException;
  127. /**
  128. * Rolls a transaction back. If a transaction is not open nothing should
  129. * happen.
  130. *
  131. * @throws SQLException
  132. * if the database access fails.
  133. */
  134. public void rollback() throws SQLException;
  135. /**
  136. * Returns a list of primary key column names. The list is either fetched
  137. * from the database (TableQuery) or given as an argument depending on
  138. * implementation.
  139. *
  140. * @return
  141. */
  142. public List<String> getPrimaryKeyColumns();
  143. /**
  144. * Performs a query to find out whether the SQL table contains a row with
  145. * the given set of primary keys.
  146. *
  147. * @param keys
  148. * the primary keys
  149. * @return true if the SQL table contains a row with the provided keys
  150. * @throws SQLException
  151. */
  152. public boolean containsRowWithKey(Object... keys) throws SQLException;
  153. /************************/
  154. /** ROWID CHANGE EVENT **/
  155. /************************/
  156. /**
  157. * An <code>Event</code> object specifying the old and new RowId of an added
  158. * item after the addition has been successfully committed.
  159. */
  160. @Deprecated
  161. public interface RowIdChangeEvent extends Serializable {
  162. /**
  163. * Gets the old (temporary) RowId of the added row that raised this
  164. * event.
  165. *
  166. * @return old RowId
  167. */
  168. public RowId getOldRowId();
  169. /**
  170. * Gets the new, possibly database assigned RowId of the added row that
  171. * raised this event.
  172. *
  173. * @return new RowId
  174. */
  175. public RowId getNewRowId();
  176. }
  177. /** RowId change listener interface. */
  178. @Deprecated
  179. public interface RowIdChangeListener extends Serializable {
  180. /**
  181. * Lets the listener know that a RowId has been changed.
  182. *
  183. * @param event
  184. */
  185. public void rowIdChange(QueryDelegate.RowIdChangeEvent event);
  186. }
  187. /**
  188. * The interface for adding and removing <code>RowIdChangeEvent</code>
  189. * listeners. By implementing this interface a class explicitly announces
  190. * that it will generate a <code>RowIdChangeEvent</code> when it performs a
  191. * database commit that may change the RowId.
  192. */
  193. @Deprecated
  194. public interface RowIdChangeNotifier extends Serializable {
  195. /**
  196. * Adds a RowIdChangeListener for the object.
  197. *
  198. * @param listener
  199. * listener to be added
  200. */
  201. public void addRowIdChangeListener(
  202. QueryDelegate.RowIdChangeListener listener);
  203. /**
  204. * @deprecated As of 7.0, replaced by
  205. * {@link #addRowIdChangeListener(RowIdChangeListener)}
  206. **/
  207. @Deprecated
  208. public void addListener(QueryDelegate.RowIdChangeListener listener);
  209. /**
  210. * Removes the specified RowIdChangeListener from the object.
  211. *
  212. * @param listener
  213. * listener to be removed
  214. */
  215. public void removeRowIdChangeListener(
  216. QueryDelegate.RowIdChangeListener listener);
  217. /**
  218. * @deprecated As of 7.0, replaced by
  219. * {@link #removeRowIdChangeListener(RowIdChangeListener)}
  220. **/
  221. @Deprecated
  222. public void removeListener(QueryDelegate.RowIdChangeListener listener);
  223. }
  224. }