[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2951) Restrictions.eq when passed null, should create a NullRestriction
Robert Nice (JIRA)
noreply at atlassian.com
Fri Jul 17 23:26:13 EDT 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2951?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33628#action_33628 ]
Robert Nice commented on HHH-2951:
----------------------------------
The attached patch won't work except for single column properties. I have composite user types that will hit a brick wall with that.
If I could figure out how to obtain column values to check for null in SimpleExpression.toSqlString I'd patch it there.
> Restrictions.eq when passed null, should create a NullRestriction
> -----------------------------------------------------------------
>
> Key: HHH-2951
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2951
> Project: Hibernate Core
> Issue Type: Improvement
> Components: query-criteria
> Affects Versions: 3.2.1
> Reporter: David Sheldon
> Priority: Trivial
> Attachments: hibernate_restrictions.patch, hibernate_restrictions2.patch
>
>
> If you create a Restriction using eq, and pass null to it, then the generated SQL is "where foo = null", which always returns false.
> The programmer will almost certainly have intended to get "where foo is null".
> Ideally, we could change:
> public static SimpleExpression eq(String propertyName, Object value) {
> return new SimpleExpression(propertyName, value, "=");
> }
> to
> public static SimpleExpression eq(String propertyName, Object value) {
> if (value == null) {
> return isNull(propertyName);
> }
> else {
> return new SimpleExpression(propertyName, value, "=");
> }
> }
> Unforunately that wont work, as isNull doesn't return a SimpleExpression.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list