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.

SQLGenerator.java 3.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.data.util.sqlcontainer.query.generator;
  5. import java.io.Serializable;
  6. import java.util.List;
  7. import com.vaadin.data.Container.Filter;
  8. import com.vaadin.data.util.sqlcontainer.RowItem;
  9. import com.vaadin.data.util.sqlcontainer.query.OrderBy;
  10. /**
  11. * The SQLGenerator interface is meant to be implemented for each different SQL
  12. * syntax that is to be supported. By default there are implementations for
  13. * HSQLDB, MySQL, PostgreSQL, MSSQL and Oracle syntaxes.
  14. *
  15. * @author Jonatan Kronqvist / Vaadin Ltd
  16. */
  17. public interface SQLGenerator extends Serializable {
  18. /**
  19. * Generates a SELECT query with the provided parameters. Uses default
  20. * filtering mode (INCLUSIVE).
  21. *
  22. * @param tableName
  23. * Name of the table queried
  24. * @param filters
  25. * The filters, converted into a WHERE clause
  26. * @param orderBys
  27. * The the ordering conditions, converted into an ORDER BY clause
  28. * @param offset
  29. * The offset of the first row to be included
  30. * @param pagelength
  31. * The number of rows to be returned when the query executes
  32. * @param toSelect
  33. * String containing what to select, e.g. "*", "COUNT(*)"
  34. * @return StatementHelper instance containing the query string for a
  35. * PreparedStatement and the values required for the parameters
  36. */
  37. public StatementHelper generateSelectQuery(String tableName,
  38. List<Filter> filters, List<OrderBy> orderBys, int offset,
  39. int pagelength, String toSelect);
  40. /**
  41. * Generates an UPDATE query with the provided parameters.
  42. *
  43. * @param tableName
  44. * Name of the table queried
  45. * @param item
  46. * RowItem containing the updated values update.
  47. * @return StatementHelper instance containing the query string for a
  48. * PreparedStatement and the values required for the parameters
  49. */
  50. public StatementHelper generateUpdateQuery(String tableName, RowItem item);
  51. /**
  52. * Generates an INSERT query for inserting a new row with the provided
  53. * values.
  54. *
  55. * @param tableName
  56. * Name of the table queried
  57. * @param item
  58. * New RowItem to be inserted into the database.
  59. * @return StatementHelper instance containing the query string for a
  60. * PreparedStatement and the values required for the parameters
  61. */
  62. public StatementHelper generateInsertQuery(String tableName, RowItem item);
  63. /**
  64. * Generates a DELETE query for deleting data related to the given RowItem
  65. * from the database.
  66. *
  67. * @param tableName
  68. * Name of the table queried
  69. * @param primaryKeyColumns
  70. * the names of the columns holding the primary key. Usually just
  71. * one column, but might be several.
  72. * @param versionColumn
  73. * the column containing the version number of the row, null if
  74. * versioning (optimistic locking) not enabled.
  75. * @param item
  76. * Item to be deleted from the database
  77. * @return StatementHelper instance containing the query string for a
  78. * PreparedStatement and the values required for the parameters
  79. */
  80. public StatementHelper generateDeleteQuery(String tableName,
  81. List<String> primaryKeyColumns, String versionColumn, RowItem item);
  82. }