I have a query that needs to also match nulls and I imagine there is a way to configure hibernate to do this automatically but have not found it.
Basically I would like the following to also evaluate true for when both the column and java object are null. At the moment because null = null evaluates as false the query never returns results. Is there a way to tell hibernate to treat empty strings and nulls as identical and produce SQL that will do this? Some databases treat empty strings as nulls..
Code:
Query q = getSession()
.createQuery(
"from IndividualCheckDO check where "
+ "check.applicant.name.title = :title "
+ "and check.applicant.name.forename = :forename "
+ "and check.applicant.name.surname = :surname "
+ "and check.current_address.flat_number = :flat_number "
+ "and check.current_address.flat_name = :flat_name "
+ "and check.current_address.house_name = :house_name "
+ "and check.current_address.house_number = :house_number "
+ "and check.current_address.street = :street "
+ "and check.current_address.postcode = :postcode");
q.setString("title", name.getTitle());
q.setString("forename", name.getForename());
q.setString("surname", name.getSurname());
q.setString("flat_number", address.getFlat_number());
q.setString("flat_name", address.getFlat_name());
q.setString("house_name", address.getHouse_name());
q.setString("house_number", address.getHouse_number());
q.setString("street", address.getStreet());
q.setString("postcode", address.getPostcode());