FreeFormQuery + SQLContainer + Table = Not Sorting

Hi everyone,

I’ve a problem and I think is related to FreeFormQuery with SQLContainer. I’m using Vaadin 6.6.2 + sqlcontainer 1.1.0.

I have a table with a big number of rows (more than 1 million) and I have a form with parameters to show a table with filtered data. The user needs to introduce parameters in order to show data in a table component.

This code works (sort with doble click in headercolumns)


// -- Build Query
TableQuery tq2= new TableQuery(TABLE_NAME,DBUtils.getConnectionPool(),new OracleGenerator(primaryKeyList));
containerSearch= new SQLContainer(tq2);

// -- Load data in table			
table.setContainerDataSource(containerSearch);
table.setVisibleColumns(formTypeColOrder);
table.setColumnHeaders(headerCaptions);
table.setHeight("100%");

I have replaced the code posted by this one…this code doesn’t sort data in table (clicking on headercolumn) :cry:


String sql = "SELECT * FROM TABLE WHERE ID='"+myCode+"'";
FreeformQuery ffq= new FreeformQuery(sql, DBUtils.getConnectionPool(), "MIPK" );
			
try {
     containerSearch= new SQLContainer(ffq);
} catch (SQLException e) {
     log.error("refreshSearch", e);
}    		
			
table.setContainerDataSource(containerSearch);
table.setVisibleColumns(formTypeColOrder);
table.setColumnHeaders(headerCaptions);
table.setHeight("100%");			

Any idea why the second code produces a table which is not able to sort by clicking header columns??

Thanks in advance.

Hi,

when using a custom query, there’s no way for the SQLContainer to know how to build the sorting query for your DB, so you have to do it yourself. See interfaces FreeformStatementDelegate and FreeformQueryDelegate, implement either one and set it to your FreeformQuery via its setDelegate method. There’s some information about this also in the
book
.

-tepi

Thanks Teppo!!! I’ll read the link and try to find examples.