How can I set a Hibernate Parameter to \"null\"? Example:
Query query = getSession().createQuery(\"from CountryDTO c where c.status = :status and c.type =:t
this seems to work as wel ->
@Override
public List findAllForThisSpecificThing(String thing) {
final Query query = entityManager.createQuery(
"from " + getDomain().getSimpleName() + " t where t.thing = " + ((thing == null) ? " null" : " :thing"));
if (thing != null) {
query.setParameter("thing", thing);
}
return query.getResultList();
}
Btw, I'm pretty new at this, so if for any reason this isn't a good idea, let me know. Thanks.