I'm using Hibernate/JPA to run the query below and I was expecting row 3 in the Table below to get returned when I pass in a null value into the Query. Both the EXPOSURE_TYPE and MESSAGE_FORMAT are defined as a Strings:
MESSAGE_FORMAT EXPOSURE_TYPE
XSD.001.001.01 1
XSD.001.001.01 2
XSD.001.001.01 null <====expecting this to get returned when i set the value to null
My Query:
Query q = em.createQuery("SELECT m FROM Message m WHERE m.messageFormat = :messageFormat AND m.exposureType = :exposureType");
q.setParameter("messageFormat", messageFormat);
q.setParameter("exposureType", exposureType);
try
{
message = (Message) q.getSingleResult();
}
catch(NoResultException nre){
//some logging
}
catch(Exception ex){
//some logging
}
return message;