public class TableQuery extends AbstractTransactionalQuery implements QueryDelegate, QueryDelegate.RowIdChangeNotifier
Modifier and Type | Class and Description |
---|---|
static class |
TableQuery.RowIdChangeEvent
Simple RowIdChangeEvent implementation.
|
QueryDelegate.RowIdChangeListener, QueryDelegate.RowIdChangeNotifier
Modifier | Constructor and Description |
---|---|
|
TableQuery(String tableName,
JDBCConnectionPool connectionPool)
Creates a new TableQuery using the given connection pool and table name
to fetch the data from.
|
|
TableQuery(String tableName,
JDBCConnectionPool connectionPool,
SQLGenerator sqlGenerator)
Creates a new TableQuery using the given connection pool, SQL generator
and table name to fetch the data from.
|
|
TableQuery(String catalogName,
String schemaName,
String tableName,
JDBCConnectionPool connectionPool,
SQLGenerator sqlGenerator)
Creates a new TableQuery using the given connection pool, SQL generator
and table name to fetch the data from.
|
protected |
TableQuery(String catalogName,
String schemaName,
String tableName,
JDBCConnectionPool connectionPool,
SQLGenerator sqlGenerator,
boolean escapeNames)
Creates a new TableQuery using the given connection pool, SQL generator
and table name to fetch the data from.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(QueryDelegate.RowIdChangeListener listener)
Deprecated.
|
void |
addRowIdChangeListener(QueryDelegate.RowIdChangeListener listener)
Adds RowIdChangeListener to this query
|
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)
Performs a query to find out whether the SQL table contains a row with
the given set of primary keys.
|
String |
getCatalogName()
Returns the catalog name for the query.
|
int |
getCount()
Generates and executes a query to determine the current row count from
the DB.
|
protected String |
getFullTableName()
Returns the complete table name obtained by concatenation of the catalog
and schema names (if any) and the table name.
|
List<String> |
getPrimaryKeyColumns()
Returns a list of primary key column names.
|
ResultSet |
getResults(int offset,
int pagelength)
Executes a paged SQL query and returns the ResultSet.
|
String |
getSchemaName()
Returns the catalog name for the query.
|
SQLGenerator |
getSqlGenerator() |
String |
getTableName()
Returns the table name for the query without catalog and schema
information.
|
String |
getVersionColumn() |
boolean |
implementationRespectsPagingLimits()
Allows the SQLContainer implementation to check whether the QueryDelegate
implementation implements paging in the getResults method.
|
void |
removeListener(QueryDelegate.RowIdChangeListener listener)
Deprecated.
|
boolean |
removeRow(RowItem row)
Removes the given RowItem from the database.
|
void |
removeRowIdChangeListener(QueryDelegate.RowIdChangeListener listener)
Removes the given RowIdChangeListener from this query
|
void |
rollback()
Rolls back and releases the active connection.
|
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.
|
void |
setVersionColumn(String column) |
int |
storeRow(RowItem row)
Stores a row in the database.
|
RowId |
storeRowImmediately(RowItem row)
Inserts the given row in the database table immediately.
|
ensureTransaction, getConnection, isInTransaction, releaseConnection
public TableQuery(String tableName, JDBCConnectionPool connectionPool, SQLGenerator sqlGenerator)
TableQuery(String, String, String, JDBCConnectionPool, SQLGenerator)
.tableName
- Name of the database table to connect toconnectionPool
- Connection pool for accessing the databasesqlGenerator
- SQL query generator implementationpublic TableQuery(String catalogName, String schemaName, String tableName, JDBCConnectionPool connectionPool, SQLGenerator sqlGenerator)
catalogName
- Name of the database catalog (can be null)schemaName
- Name of the database schema (can be null)tableName
- Name of the database table to connect toconnectionPool
- Connection pool for accessing the databasesqlGenerator
- SQL query generator implementationpublic TableQuery(String tableName, JDBCConnectionPool connectionPool)
TableQuery(String, String, String, JDBCConnectionPool, SQLGenerator)
.tableName
- Name of the database table to connect toconnectionPool
- Connection pool for accessing the databaseprotected TableQuery(String catalogName, String schemaName, String tableName, JDBCConnectionPool connectionPool, SQLGenerator sqlGenerator, boolean escapeNames)
catalogName
- Name of the database catalog (can be null)schemaName
- Name of the database schema (can be null)tableName
- Name of the database table to connect toconnectionPool
- Connection pool for accessing the databasesqlGenerator
- SQL query generator implementationescapeNames
- true to escape special characters in catalog, schema and table
names, false to use the names as-ispublic int getCount() throws SQLException
QueryDelegate
getCount
in interface QueryDelegate
SQLException
public ResultSet getResults(int offset, int pagelength) throws SQLException
QueryDelegate
getResults
in interface QueryDelegate
offset
- the first item of the page to loadpagelength
- the length of the page to loadSQLException
- if the database access fails.public boolean implementationRespectsPagingLimits()
QueryDelegate
implementationRespectsPagingLimits
in interface QueryDelegate
QueryDelegate.getResults(int, int)
public int storeRow(RowItem row) throws UnsupportedOperationException, SQLException
QueryDelegate
storeRow
in interface QueryDelegate
UnsupportedOperationException
- if the implementation is read only.SQLException
public RowId storeRowImmediately(RowItem row) throws SQLException
row
- RowItem to add to the databaseSQLException
public void setFilters(List<Container.Filter> filters) throws UnsupportedOperationException
QueryDelegate
setFilters
in interface QueryDelegate
filters
- The filters to apply.UnsupportedOperationException
- if the implementation doesn't support filtering.public void setOrderBy(List<OrderBy> orderBys) throws UnsupportedOperationException
QueryDelegate
setOrderBy
in interface QueryDelegate
orderBys
- A list of the OrderBy conditions.UnsupportedOperationException
- if the implementation doesn't support ordering.public void beginTransaction() throws UnsupportedOperationException, SQLException
AbstractTransactionalQuery
beginTransaction
in interface QueryDelegate
beginTransaction
in class AbstractTransactionalQuery
SQLException
- if a connection could not be obtained or configuredUnsupportedOperationException
public void commit() throws UnsupportedOperationException, SQLException
AbstractTransactionalQuery
commit
in interface QueryDelegate
commit
in class AbstractTransactionalQuery
SQLException
- if not in a transaction managed by this queryUnsupportedOperationException
public void rollback() throws UnsupportedOperationException, SQLException
AbstractTransactionalQuery
rollback
in interface QueryDelegate
rollback
in class AbstractTransactionalQuery
SQLException
- if not in a transaction managed by this queryUnsupportedOperationException
public List<String> getPrimaryKeyColumns()
QueryDelegate
getPrimaryKeyColumns
in interface QueryDelegate
public String getVersionColumn()
public void setVersionColumn(String column)
public String getTableName()
public String getCatalogName()
public String getSchemaName()
protected String getFullTableName()
public SQLGenerator getSqlGenerator()
public boolean removeRow(RowItem row) throws UnsupportedOperationException, SQLException
QueryDelegate
removeRow
in interface QueryDelegate
row
- RowItem to be removedUnsupportedOperationException
SQLException
public boolean containsRowWithKey(Object... keys) throws SQLException
QueryDelegate
containsRowWithKey
in interface QueryDelegate
keys
- the primary keysSQLException
public void addRowIdChangeListener(QueryDelegate.RowIdChangeListener listener)
addRowIdChangeListener
in interface QueryDelegate.RowIdChangeNotifier
listener
- listener to be added@Deprecated public void addListener(QueryDelegate.RowIdChangeListener listener)
addRowIdChangeListener(com.vaadin.data.util.sqlcontainer.query.QueryDelegate.RowIdChangeListener)
addListener
in interface QueryDelegate.RowIdChangeNotifier
public void removeRowIdChangeListener(QueryDelegate.RowIdChangeListener listener)
removeRowIdChangeListener
in interface QueryDelegate.RowIdChangeNotifier
listener
- listener to be removed@Deprecated public void removeListener(QueryDelegate.RowIdChangeListener listener)
removeRowIdChangeListener(com.vaadin.data.util.sqlcontainer.query.QueryDelegate.RowIdChangeListener)
removeListener
in interface QueryDelegate.RowIdChangeNotifier
Copyright © 2016 Vaadin Ltd. All rights reserved.