The LIKE expression has the format string LIKE pattern, where pattern must be a string literal. In SQL, string literals must be enclosed in single quotes. So you would use something like
"trim(" + alias + "bar) like '%" + filter.getBar() + "'"
to get
where trim(this.bar) like '%2'