|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.vaadin.data.util.sqlcontainer.query.FreeformQuery
public class FreeformQuery
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.vaadin.data.util.sqlcontainer.query.QueryDelegate |
|---|
QueryDelegate.RowIdChangeEvent, QueryDelegate.RowIdChangeListener, QueryDelegate.RowIdChangeNotifier |
| Constructor Summary | |
|---|---|
FreeformQuery(java.lang.String queryString,
JDBCConnectionPool connectionPool,
java.lang.String... primaryKeyColumns)
Creates a new freeform query delegate to be used with the SQLContainer. |
|
FreeformQuery(java.lang.String queryString,
java.util.List<java.lang.String> primaryKeyColumns,
JDBCConnectionPool connectionPool)
Deprecated. As of 6.7, @see FreeformQuery(String, JDBCConnectionPool, String...) |
|
| Method Summary | |
|---|---|
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(java.lang.Object... keys)
This implementation of the containsRowWithKey method rewrites existing WHERE clauses in the query string. |
protected void |
ensureTransaction()
Check that a transaction is active. |
protected java.sql.Connection |
getConnection()
Returns the currently active connection, reserves and returns a new connection if no active connection. |
int |
getCount()
This implementation of getCount() actually fetches all records from the database, which might be a performance issue. |
FreeformQueryDelegate |
getDelegate()
|
java.util.List<java.lang.String> |
getPrimaryKeyColumns()
Returns a list of primary key column names. |
java.lang.String |
getQueryString()
|
java.sql.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. |
protected boolean |
isInTransaction()
|
protected void |
releaseConnection(java.sql.Connection conn,
java.sql.Statement statement,
java.sql.ResultSet rs)
Closes a statement and a resultset, then releases the connection if it is not part of an active transaction. |
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(java.util.List<Container.Filter> filters)
Sets the filters to apply when performing the SQL query. |
void |
setOrderBy(java.util.List<OrderBy> orderBys)
Sets the order in which to retrieve rows from the database. |
int |
storeRow(RowItem row)
Stores a row in the database. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
@Deprecated
public FreeformQuery(java.lang.String queryString,
java.util.List<java.lang.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(java.lang.String queryString,
JDBCConnectionPool connectionPool,
java.lang.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)| Method Detail |
|---|
public int getCount()
throws java.sql.SQLException
getCount in interface QueryDelegatejava.sql.SQLException
public java.sql.ResultSet getResults(int offset,
int pagelength)
throws java.sql.SQLException
getResults in interface QueryDelegateoffset - the first item of the page to loadpagelength - the length of the page to load
java.sql.SQLExceptionFreeformQueryDelegate.getQueryString(int, int)public boolean implementationRespectsPagingLimits()
QueryDelegate
implementationRespectsPagingLimits in interface QueryDelegateQueryDelegate.getResults(int, int)
public void setFilters(java.util.List<Container.Filter> filters)
throws java.lang.UnsupportedOperationException
QueryDelegate
setFilters in interface QueryDelegatefilters - The filters to apply.
java.lang.UnsupportedOperationException - if the implementation doesn't support filtering.
public void setOrderBy(java.util.List<OrderBy> orderBys)
throws java.lang.UnsupportedOperationException
QueryDelegate
setOrderBy in interface QueryDelegateorderBys - A list of the OrderBy conditions.
java.lang.UnsupportedOperationException - if the implementation doesn't support ordering.
public int storeRow(RowItem row)
throws java.sql.SQLException
QueryDelegate
storeRow in interface QueryDelegatejava.sql.SQLException
public boolean removeRow(RowItem row)
throws java.sql.SQLException
QueryDelegate
removeRow in interface QueryDelegaterow - RowItem to be removed
java.sql.SQLException
public void beginTransaction()
throws java.lang.UnsupportedOperationException,
java.sql.SQLException
beginTransaction in interface QueryDelegatejava.sql.SQLException - if a connection could not be obtained or configured
java.lang.UnsupportedOperationException
public void commit()
throws java.lang.UnsupportedOperationException,
java.sql.SQLException
commit in interface QueryDelegatejava.sql.SQLException - if not in a transaction managed by this query
java.lang.UnsupportedOperationException
public void rollback()
throws java.lang.UnsupportedOperationException,
java.sql.SQLException
rollback in interface QueryDelegatejava.sql.SQLException - if not in a transaction managed by this query
java.lang.UnsupportedOperationExceptionpublic java.util.List<java.lang.String> getPrimaryKeyColumns()
QueryDelegate
getPrimaryKeyColumns in interface QueryDelegatepublic java.lang.String getQueryString()
public FreeformQueryDelegate getDelegate()
public void setDelegate(FreeformQueryDelegate delegate)
public boolean containsRowWithKey(java.lang.Object... keys)
throws java.sql.SQLException
containsRowWithKey in interface QueryDelegatekeys - the primary keys
java.sql.SQLExceptionFreeformQueryDelegate.getContainsRowQueryString(Object...)
protected void ensureTransaction()
throws java.sql.SQLException
java.sql.SQLException - if no active transaction
protected void releaseConnection(java.sql.Connection conn,
java.sql.Statement statement,
java.sql.ResultSet rs)
throws java.sql.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
java.sql.SQLException - if closing the result set or the statement fails
protected java.sql.Connection getConnection()
throws java.sql.SQLException
java.sql.SQLExceptionprotected boolean isInTransaction()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||