0
I have the following method that does a database search:
public Collection<Habilidade> pesquisar(HabilidadeForm form) throws Exception {
String query = "select u from Habilidade u where u.nome like ?1 and u.geracao = ?2";
Collection<Habilidade> resultado =
em.createQuery(query).setParameter(1, "%" + form.getNome() + "%")
.setParameter(2, form.getGeracao()).getResultList();
return resultado.isEmpty() ? findAll() : resultado;
}
If I do the same query in the database would be an example:
select * from habilidade where nome like '%Bl%' and geracao_id = null;
I have a problem where no generation is null, so I fall for the catch that it will not bring anything if generation is null. How can I choose to do for example: If the generation is null ignore ?