Why examples from wiki/Addons/SQLContainer doesn't work?

For example, this example doesn’t provide contents filtration -


public static void main(String args[]) {
  SimpleJDBCConnectionPool connPool = new SimpleJDBCConnectionPool();
  SQLContainer container = null;
  try {
    container = new SQLContainer(new FreeformQuery(
            "SELECT * FROM users AS u INNER JOIN roles AS r ON u.role_id = r.id ORDER BY u.name ASC, r.name ASC",
            connPool));
    container.addFilter(new Filter("name", ComparisonType.STARTS_WITH, "Dave"));
    Table table = new Table("All our Daves", container);
    container.sort(new Object[] {"name", "role"}, new boolean[]
 {true, true});
  } catch(SQLException e) {
    if (container != null) {
      container.rollback();
    }
    e.printStackTrace();
  }
}

Hi,

I could not instantly find the page in wiki you are referring to, but I can see what is wrong with the example: When using a FreeformQuery with the SQLContainer, you must implement a FreeformQueryDelegate yourself to provide support for e.g. lazy loading, filtering and sorting. The example is throwing a UnsupportedOperationException, right?

So you have two options to make this work:

  • Use TableQuery (and lose ‘advanced’ query options)
  • Implement the FreeformQueryDelegate interface

The SQLContainer demos/examples should provide some pointers to each of these tasks.


Tepi

Oh, now I found the page:
SQLContainer specification

This is actually a pre-implementation specification of the SQLContainer, hence the examples there are kind of “pseudo-code” in the sense that they were written before the SQLContainer was written. You may want to refer to the
manual
for more real examples and instructions.


Tepi

I welcome you, Teppo Kurki!

Many thanks! I have read instructions and have familiarized with an example from
here

I am very grateful to you for the rendered consultation and if you not against, would like to continue our dialogue
here
as remained some question with realization FreeformQueryDelegate.