If I have a JQL query in hibernate select c from Customer c where c.col=:col
Is there a way to get hibernate to send the query prepopulated to JDBC preparedstatement?
ie. Can I get hibernate to send this
select c.col, c.name, c.id, etc from Customer c where c.col=value (or NULL)
instead of
select c.col, c.name, c.id, etc from Customer c where c.col=?
Ideally hibernate would also tweak the Strings correctly so SQL injection is prevented as well.
postgres has a setting so null = null and people have been making mistakes thinking null = null without that setting. I actually think null = nulll should work and makes more sense myself. However, in SQL, "WHERE c.col = :col" are not equal if both sides are null. We realize this is a deviation from SQL spec but it's better to not be introducing all these bugs going forward as we hire more junior engineers. ie. better to have a stable product and business then follow some standard in some cases so we can move fast without worry of those bugs.
There are a ton of questions on SO also about null != null in SQL. I am also not very sure why "c.col is null" gets to be correct while "c.col = null" is wrong and returns 0 rows always. I think some people desire to never have null and want c.col = null to 'fail' but of course, it really fails silently which is more annoying since we don't catch the bug. If it failed hard core, at least our developers would then stop and ask, what in the world is going on.