Read that TableQuery supports sorting & filtering and that is what i am looking for whereas FreeFormQuery helps us to pass complex query bt sorting & filtering needs to be implemented .
So just trying to work on Tablequery .I hve two questions on the same :
I am trying to sort the table. I have a primary Key (ID) n two other columns Name & Role,
Whn i sort wrt ID, the order of sorting will be ascending / descending. But when i try the same wrt Name Column &
Role Column, its returning me a random sort. Is it possible to sort the Name & Role column in ascending &
descending manner just as the ID column works.?
Below is my code:
SimpleJDBCConnectionPool connPool = new SimpleJDBCConnectionPool();
try {
container = new SQLContainer(new TableQuery(“users”, connPool));
Table table = new Table(“Employee”, container);
container.sort(new Object {“Name”, “Role”}, new boolean
{true, true});
}
catch(SQLException e) {
getMainWindow().showNotification(
“SQLException while processing”,
e.getLocalizedMessage());
e.printStackTrace();
}
The sample examples i have cme across wrt Tablequery loads the complete table .Is there a way to pass the query to pickup certain columns via TableQuery ?
Sorting in TableQueries adds ORDER BY to the SQL query. Please check that the generated queries actually do work by setting SQLContainer in debug mode (setDebugMode(true)) and test that the queries return correct results.
As for TableQuery always querying all columns, this is the way it has been designed. You can hide certain columns in Table components by calling Table.setVisibleColumns(), for instance. If you want more control over your query, you should use FreeformQuery.
I tried setting the container to debug mode, but no success
The DB is Mysql…I need a container which provides an option to sort.
SQLContainer is providing an option to sort bt not to the columns wit string values .I would need to sort the strings as well in ascending & descending manner just like the ID (integer sorting)
Can anyone suggest.??
Has anyone implemented sorting in FreeFormQuery???