SQLGenerator.generateSelectQuery() ignores filters' strings

Hi
I’m adding filters to a
SQLContainer
using
addContainerFilter()
but they never seem to work.
Digging deeper to find the cause of the problem I found out that the query string returned by
SQLGenerator.generateSelectQuery()
is incorect/incomplete.
What exactly happens is that applying filters like

[code]

  1. contactsContainer.addContainerFilter(new Compare.Equal(“name”, “Johnson”));
  2. contactsContainer.addContainerFilter(new Compare.Greater(“age”, “18”));
    [/code]results with the following being executed on the database:

[code]

  1. SELECT COUNT(*) FROM contacts WHERE “name” = ?
  2. SELECT COUNT(*) FROM firmy WHERE “age” > ?
    [/code]As you can see, the filter type is correctly interpreted but the condition string is always a
    ?
    .
    Is it me doing some silly mistake, a problem with my current configuration or a real bug that should be reported?
    I’m using Vaadin 7.1.5.

Hi,

did you actually confirm that the executed statements have those question marks as parameters or is this just a log output? In the latter case I think the output is correct since it uses PreparedStatements and if you print on out it just outputs the query string without the parameters in place, so each parameter will be a ? in the log output. The parameters are set to the PreparedStatement before executing it. If you want to follow it with a debugger a good location would be com.vaadin.data.util.sqlcontainer.query.generator.StatementHelper.setParameterValuesToStatement(PreparedStatement) which handles placing the values to the statement.

You were right, the queries were correct, I just wasn’t checking them in the correct place.
I implemented a FreeformStatementDelegate just to find out that my table’s misbehaviour was caused by an unsuported column name decorator. Calling QueryBuilder.setStringDecorator(new StringDecorator("`", "`")); solved my problem. Thanks for your suggestion.