Code example with Hibernate which evaluate possible parameters:
String query = "SELECT * FROM instances";
String where = "";
if(userName!=null) {
where+="AND username = '" + userName + "'";
}
if(componentName!=null) {
where+="AND componentname = '" + componentName + "'";
}
if(componentAlias!=null) {
where+="AND componentalias = '" + componentAlias + "'";
}
if(!where.equalsIgnoreCase("")) {
where = where.substring(3);
where = " WHERE " + where;
}
query = query + where;
LOGGER.info("Query: " + query);
Statement s = (Statement) conn.createStatement();
ResultSet rs = s.executeQuery(query);
How can I do that with Speedment ORM Filters?