Implementing FreeformStatementDelegate

Hi all!
I’m using FreeformQuery to make queries on more than 1 table. I also want to have sortable columns so I need to implement my own FreeformStatementDelegate, problem is that I don’t know which methods I have to implement and how implement them because I can’t found enough information about each method nor examples. So please tell me what I have to do, I “googled” a lot last days but I couldn’t found a way…

If you implement FreeformStatementDelegate, its methods are used rather than the corresponding deprecated methods of FreeformQueryDelegate. Thus, implement all non-deprecated methods from both delegates (FSD and FQD) but you can use empty methods or throw UnsupportedOperationException for the three deprecated methods in FQD.

Ok, but how should I implement them?

Typically the methods of FreeformStatementDelegate are of the form “return new StatementHelper(“my sql query”);” and storeRow()/removeRow() perform a suitable update if writes are supported, otherwise just throw new UnsupportedOperationException(…).

The methods setFilters(List) and setOrderBy(List) should just store the current set of filters and sort criteria to be used when constructing your queries.

See the javadoc for explanations about what the methods should do. You can also take a look at SQLGenerator, its implementation DefaultSQLGenerator and QueryBuilder that are used by TableQuery to construct StatementHelper instances for TableQuery, using filters and sort criteria.