[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3316) If expression support in the criteria API

Avlesh Singh (JIRA) noreply at atlassian.com
Fri May 30 04:23:33 EDT 2008


If expression support in the criteria API
-----------------------------------------

                 Key: HHH-3316
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3316
             Project: Hibernate3
          Issue Type: Improvement
          Components: query-criteria
         Environment: Hibernate 3, MySQL 4.1
            Reporter: Avlesh Singh
            Priority: Minor


MySQL supports IF() as one of the Control Flow Structures. I am not too sure if other dialects support an equivalent. 
This is how it works - 
SELECT IF(1>2,2,3);
     -> 3

To the best of my knowledge, there is no implementation in the Restrictions/Expression class for this control structure. Underneath is what I am talking about this implementation in the Expression class
public static org.hibernate.criterion.Criterion ifExpression(org.hibernate.criterion.Criterion criterion, java.lang.Object trueValue, java.lang.Object falseValue){}

for which usage would typically look like this-
Criteria queryCriteria = session.createCriteria(MyBean.class);
queryCriteria.add(Expression.ifExpression(Expression.isNull("myProperty"), "myProperty", new Date()));

the bean definition is underneath -
class MyBean{
 private Date myProperty;
}

I would love to hear from others on this.

-- 
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