public class FreeformQuery extends AbstractTransactionalQuery implements QueryDelegate
QueryDelegate.RowIdChangeEvent, QueryDelegate.RowIdChangeListener, QueryDelegate.RowIdChangeNotifier| Constructor and Description |
|---|
FreeformQuery(String queryString,
JDBCConnectionPool connectionPool,
String... primaryKeyColumns)
Creates a new freeform query delegate to be used with the
SQLContainer. |
FreeformQuery(String queryString,
List<String> primaryKeyColumns,
JDBCConnectionPool connectionPool)
Deprecated.
As of 6.7, @see
FreeformQuery(String, JDBCConnectionPool, String...) |
| Modifier and Type | Method and Description |
|---|---|
void |
beginTransaction()
Reserves a connection with auto-commit off if no transaction is in
progress.
|
void |
commit()
Commits (if not in auto-commit mode) and releases the active connection.
|
boolean |
containsRowWithKey(Object... keys)
This implementation of the containsRowWithKey method rewrites existing
WHERE clauses in the query string.
|
int |
getCount()
This implementation of getCount() actually fetches all records from the
database, which might be a performance issue.
|
FreeformQueryDelegate |
getDelegate() |
List<String> |
getPrimaryKeyColumns()
Returns a list of primary key column names.
|
String |
getQueryString() |
ResultSet |
getResults(int offset,
int pagelength)
Fetches the results for the query.
|
boolean |
implementationRespectsPagingLimits()
Allows the SQLContainer implementation to check whether the QueryDelegate
implementation implements paging in the getResults method.
|
boolean |
removeRow(RowItem row)
Removes the given RowItem from the database.
|
void |
rollback()
Rolls back and releases the active connection.
|
void |
setDelegate(FreeformQueryDelegate delegate) |
void |
setFilters(List<Container.Filter> filters)
Sets the filters to apply when performing the SQL query.
|
void |
setOrderBy(List<OrderBy> orderBys)
Sets the order in which to retrieve rows from the database.
|
int |
storeRow(RowItem row)
Stores a row in the database.
|
ensureTransaction, getConnection, isInTransaction, releaseConnection@Deprecated public FreeformQuery(String queryString, List<String> primaryKeyColumns, JDBCConnectionPool connectionPool)
FreeformQuery(String, JDBCConnectionPool, String...)SQLContainer.queryString - The actual query to perform.primaryKeyColumns - The primary key columns. Read-only mode is forced if this
parameter is null or empty.connectionPool - the JDBCConnectionPool to use to open connections to the SQL
database.public FreeformQuery(String queryString, JDBCConnectionPool connectionPool, String... primaryKeyColumns)
SQLContainer.queryString - The actual query to perform.connectionPool - the JDBCConnectionPool to use to open connections to the SQL
database.primaryKeyColumns - The primary key columns. Read-only mode is forced if none are
provided. (optional)public int getCount()
throws SQLException
getCount in interface QueryDelegateSQLExceptionpublic ResultSet getResults(int offset, int pagelength) throws SQLException
getResults in interface QueryDelegateoffset - the first item of the page to loadpagelength - the length of the page to loadSQLExceptionFreeformQueryDelegate.getQueryString(int, int)public boolean implementationRespectsPagingLimits()
QueryDelegateimplementationRespectsPagingLimits in interface QueryDelegateQueryDelegate.getResults(int, int)public void setFilters(List<Container.Filter> filters) throws UnsupportedOperationException
QueryDelegatesetFilters in interface QueryDelegatefilters - The filters to apply.UnsupportedOperationException - if the implementation doesn't support filtering.public void setOrderBy(List<OrderBy> orderBys) throws UnsupportedOperationException
QueryDelegatesetOrderBy in interface QueryDelegateorderBys - A list of the OrderBy conditions.UnsupportedOperationException - if the implementation doesn't support ordering.public int storeRow(RowItem row) throws SQLException
QueryDelegatestoreRow in interface QueryDelegateSQLExceptionpublic boolean removeRow(RowItem row) throws SQLException
QueryDelegateremoveRow in interface QueryDelegaterow - RowItem to be removedSQLExceptionpublic void beginTransaction()
throws UnsupportedOperationException,
SQLException
AbstractTransactionalQuerybeginTransaction in interface QueryDelegatebeginTransaction in class AbstractTransactionalQuerySQLException - if a connection could not be obtained or configuredUnsupportedOperationExceptionpublic void commit()
throws UnsupportedOperationException,
SQLException
AbstractTransactionalQuerycommit in interface QueryDelegatecommit in class AbstractTransactionalQuerySQLException - if not in a transaction managed by this queryUnsupportedOperationExceptionpublic void rollback()
throws UnsupportedOperationException,
SQLException
AbstractTransactionalQueryrollback in interface QueryDelegaterollback in class AbstractTransactionalQuerySQLException - if not in a transaction managed by this queryUnsupportedOperationExceptionpublic List<String> getPrimaryKeyColumns()
QueryDelegategetPrimaryKeyColumns in interface QueryDelegatepublic String getQueryString()
public FreeformQueryDelegate getDelegate()
public void setDelegate(FreeformQueryDelegate delegate)
public boolean containsRowWithKey(Object... keys) throws SQLException
containsRowWithKey in interface QueryDelegatekeys - the primary keysSQLExceptionFreeformQueryDelegate.getContainsRowQueryString(Object...)Copyright © 2016 Vaadin Ltd. All rights reserved.