com.vaadin.data.util.sqlcontainer.query.
Interface QueryDelegate
All Superinterfaces:
All Known Implementing Classes:
- extends Serializable
public interface QueryDelegate
Nested Class Summary | |
---|---|
static interface |
QueryDelegate.RowIdChangeEvent
An Event object specifying the old and new RowId of an added
item after the addition has been successfully committed. |
static interface |
QueryDelegate.RowIdChangeListener
RowId change listener interface. |
static interface |
QueryDelegate.RowIdChangeNotifier
The interface for adding and removing RowIdChangeEvent
listeners. |
Method Summary | |
---|---|
void |
beginTransaction()
Starts a new database transaction. |
void |
commit()
Commits a transaction. |
boolean |
containsRowWithKey(Object... keys)
Performs a query to find out whether the SQL table contains a row with the given set of primary keys. |
int |
getCount()
Generates and executes a query to determine the current row count from the DB. |
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. |
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 a transaction back. |
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. |
Method Detail |
---|
getCount
int getCount()
throws SQLException
- Returns:
- row count
- Throws:
SQLException
Generates and executes a query to determine the current row count from the DB. Row count will be fetched using filters that are currently set to the QueryDelegate.
getResults
ResultSet getResults(int offset,
int pagelength)
throws SQLException
- Parameters:
offset
- the first item of the page to loadpagelength
- the length of the page to load- Returns:
- a ResultSet containing the rows of the page
- Throws:
SQLException
- if the database access fails.
Executes a paged SQL query and returns the ResultSet. The query is defined through implementations of this QueryDelegate interface.
implementationRespectsPagingLimits
boolean implementationRespectsPagingLimits()
- Returns:
- true if the delegate implements paging
- See Also:
getResults(int, int)
Allows the SQLContainer implementation to check whether the QueryDelegate implementation implements paging in the getResults method.
setFilters
void setFilters(List<Container.Filter> filters)
throws UnsupportedOperationException
- Parameters:
filters
- The filters to apply.- Throws:
UnsupportedOperationException
- if the implementation doesn't support filtering.
Sets the filters to apply when performing the SQL query. These are translated into a WHERE clause. Default filtering mode will be used.
setOrderBy
void setOrderBy(List<OrderBy> orderBys)
throws UnsupportedOperationException
- Parameters:
orderBys
- A list of the OrderBy conditions.- Throws:
UnsupportedOperationException
- if the implementation doesn't support ordering.
Sets the order in which to retrieve rows from the database. The result can be ordered by zero or more columns and each column can be in ascending or descending order. These are translated into an ORDER BY clause in the SQL query.
storeRow
int storeRow(RowItem row)
throws UnsupportedOperationException,
SQLException
- Parameters:
columnToValueMap
- A map containing the values for all columns to be stored or updated.- Returns:
- the number of affected rows in the database table
- Throws:
UnsupportedOperationException
- if the implementation is read only.SQLException
Stores a row in the database. The implementation of this interface decides how to identify whether to store a new row or update an existing one.
removeRow
boolean removeRow(RowItem row)
throws UnsupportedOperationException,
SQLException
- Parameters:
row
- RowItem to be removed- Returns:
- true on success
- Throws:
UnsupportedOperationException
SQLException
Removes the given RowItem from the database.
beginTransaction
void beginTransaction()
throws SQLException
- Throws:
SQLException
- if the database access fails.
Starts a new database transaction. Used when storing multiple changes. Note that if a transaction is already open, it will be rolled back when a new transaction is started.
commit
void commit()
throws SQLException
- Throws:
SQLException
- if the database access fails.
Commits a transaction. If a transaction is not open nothing should happen.
rollback
void rollback()
throws SQLException
- Throws:
SQLException
- if the database access fails.
Rolls a transaction back. If a transaction is not open nothing should happen.
getPrimaryKeyColumns
List<String> getPrimaryKeyColumns()
- Returns:
Returns a list of primary key column names. The list is either fetched from the database (TableQuery) or given as an argument depending on implementation.
containsRowWithKey
boolean containsRowWithKey(Object... keys)
throws SQLException
- Parameters:
keys
- the primary keys- Returns:
- true if the SQL table contains a row with the provided keys
- Throws:
SQLException
Performs a query to find out whether the SQL table contains a row with the given set of primary keys.