I have the following method that searches the database:
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 into the trap that it will not bring anything if the generation is null. How can I resolve to do for example: If the generation is null ignore?