Making Freeform Queries
Getting started with the FreeformQuery may be done as shown in the following. The connection pool initialization is similar to the TableQuery example so it is omitted here. Note that the name(s) of the primary key column(s) must be provided to the FreeformQuery manually. This is required because depending on the query the result set may or may not contain data about primary key columns. In this example, there is one primary key column with a name ‘ID’.
The FreeformStatementDelegate interface is an extension of the FreeformQueryDelegate interface, which returns StatementHelper objects instead of pure query String#s. This enables the developer to use prepared statetemens instead of regular statements. It is highly recommended to use the [classname]#FreeformStatementDelegate in all implementations. From this chapter onwards, we will only refer to the FreeformStatementDelegate in cases where FreeformQueryDelegate could also be applied.
public StatementHelper getCountStatement()
public StatementHelper getContainsRowQueryStatement(Object... keys)
// Filtering and sorting
public void setFilters(List<Filter> filters)
public void setFilters(List<Filter> filters,
public void setOrderBy(List<OrderBy> orderBys)
// Write support
public boolean removeRow(Connection conn, RowItem row)
A simple demo implementation of this interface can be found in the SQLContainer package, more specifically in the class com.vaadin.addon.sqlcontainer.demo.DemoFreeformQueryDelegate.