You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Tauren Mills <ta...@groovee.com> on 2007/08/15 09:11:37 UTC

Using non-string parameters in HibernateContactFinderQueryBuilder

I have a data table based on wicket-phonebook, but have added an
additional column that contains non-string data.  In the database, the
value is an int, but the application maps that to a string using a
custom enumeration type with a converter to handle all this.

The table display, editing, and so forth of the data table works fine.
 And I have the FilterToolbar showing a choice list of the possible
values in the enumeration.  When one of the values is selected, the
rows with that value are displayed.

The problem is that HibernateContactFinderQueryBuilder assumes all
filter parameters are strings.  So I've hacked it to work by letting
the int get converted to a string:

private void addEnumCondition(StringBuilder hql,
		Enumeration enumeration, String name) {
	if (enumeration != null) {
		hql.append("and target.");
		hql.append(name);
		hql.append(" = ? ");
		parameters.add(""+enumeration.getValue());
		types.add(Hibernate.STRING);
	}
}

Obviously, this isn't very elegant.  But I'm unclear on what would be
a better approach.  I tried to use a List<Object> instead of
List<String>, but then I ran into other exceptions and didn't dig into
them deeper.

Plus, I'm having problems with the filter choice not persisting the
last selected value like it does for the Last Name column.  It always
goes back to "Choose one...", even if the table is filtered with a
value from the enumeration.  And selecting the blank row in the choice
list results in no data rather than all data.

I guess I'm looking for some suggestions or ideas if anyone has any.

Thanks,
Tauren

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org