|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.vaadin.data.util.sqlcontainer.query.TableQuery
public class TableQuery
Nested Class Summary | |
---|---|
class |
TableQuery.RowIdChangeEvent
Simple RowIdChangeEvent implementation. |
Nested classes/interfaces inherited from interface com.vaadin.data.util.sqlcontainer.query.QueryDelegate |
---|
QueryDelegate.RowIdChangeListener, QueryDelegate.RowIdChangeNotifier |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
void |
addListener(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. |
protected void |
ensureTransaction()
Check that a transaction is active. |
protected Connection |
getConnection()
Returns the currently active connection, reserves and returns a new connection if no active connection. |
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. |
SQLGenerator |
getSqlGenerator()
|
String |
getTableName()
|
String |
getVersionColumn()
|
boolean |
implementationRespectsPagingLimits()
Allows the SQLContainer implementation to check whether the QueryDelegate implementation implements paging in the getResults method. |
protected boolean |
isInTransaction()
|
protected void |
releaseConnection(Connection conn,
Statement statement,
ResultSet rs)
Closes a statement and a resultset, then releases the connection if it is not part of an active transaction. |
void |
removeListener(QueryDelegate.RowIdChangeListener listener)
Removes the given RowIdChangeListener from this query |
boolean |
removeRow(RowItem row)
Removes the given RowItem from the database. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TableQuery(String tableName, JDBCConnectionPool connectionPool, SQLGenerator sqlGenerator)
tableName
- Name of the database table to connect toconnectionPool
- Connection pool for accessing the databasesqlGenerator
- SQL query generator implementationpublic TableQuery(String tableName, JDBCConnectionPool connectionPool)
tableName
- Name of the database table to connect toconnectionPool
- Connection pool for accessing the databaseMethod Detail |
---|
public 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 load
SQLException
- 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 database
SQLException
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
beginTransaction
in interface QueryDelegate
SQLException
- if a connection could not be obtained or configured
UnsupportedOperationException
public void commit() throws UnsupportedOperationException, SQLException
commit
in interface QueryDelegate
SQLException
- if not in a transaction managed by this query
UnsupportedOperationException
public void rollback() throws UnsupportedOperationException, SQLException
rollback
in interface QueryDelegate
SQLException
- if not in a transaction managed by this query
UnsupportedOperationException
public List<String> getPrimaryKeyColumns()
QueryDelegate
getPrimaryKeyColumns
in interface QueryDelegate
public String getVersionColumn()
public void setVersionColumn(String column)
public String getTableName()
public SQLGenerator getSqlGenerator()
public boolean removeRow(RowItem row) throws UnsupportedOperationException, SQLException
QueryDelegate
removeRow
in interface QueryDelegate
row
- RowItem to be removed
UnsupportedOperationException
SQLException
public boolean containsRowWithKey(Object... keys) throws SQLException
QueryDelegate
containsRowWithKey
in interface QueryDelegate
keys
- the primary keys
SQLException
public void addListener(QueryDelegate.RowIdChangeListener listener)
addListener
in interface QueryDelegate.RowIdChangeNotifier
listener
- listener to be addedpublic void removeListener(QueryDelegate.RowIdChangeListener listener)
removeListener
in interface QueryDelegate.RowIdChangeNotifier
listener
- listener to be removedprotected void ensureTransaction() throws SQLException
SQLException
- if no active transactionprotected void releaseConnection(Connection conn, Statement statement, ResultSet rs) throws SQLException
PreparedStatement
, its parameters are
cleared prior to closing the statement.
Although JDBC specification does state that closing a statement closes
its result set and closing a connection closes statements and result
sets, this method does try to close the result set and statement
explicitly whenever not null. This can guard against bugs in certain JDBC
drivers and reduce leaks in case e.g. closing the result set succeeds but
closing the statement or connection fails.
conn
- the connection to releasestatement
- the statement to close, may be null to skip closingrs
- the result set to close, may be null to skip closing
SQLException
- if closing the result set or the statement failsprotected Connection getConnection() throws SQLException
SQLException
protected boolean isInTransaction()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |