Great and easy solution! I just added case insensitivity, and retrieve the next:
String first = “%” + first + “%”;
String second= “%” + second + “%”;
Query query = Query.select().
.where(
"(LOWER(a) LIKE LOWER(?) OR LOWER(a) LIKE LOWER(?)) +
" AND b = (?)", first, second, third);
I hope this solution will help not only me. @clouless, thanks again )
I struggled for quite some time and there was not much documentation
@OleksiiSkachkov You should be careful with LOWER() I cannot exactly remember which database engine had problems with that but I test my app against MySQL, PostgreSQL, Oracle and MSSQL and one of them had problems with LOWER(). That is why I created these lowercase shadow columns as a workaround. But maybe active objects can now handle it
And also be careful. AND is stronger than OR. So you really need some extra brackets. ( some LIKE ? OR other LIKE ? ) AND foo = ?
In case when alias are used the column name only needs to go in quotes e.g.
String lowerFunction = ao.moduleMetaData().getDatabaseType() == DatabaseType.MYSQL? “LOWER(alias.NAME)” : “LOWER(alias."NAME")”;