[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3316) If expression support in the criteria API
Gail Badner (JIRA)
noreply at atlassian.com
Fri May 30 18:45:33 EDT 2008
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_30290 ]
Gail Badner commented on HHH-3316:
----------------------------------
The improvement should really support a CASE expression, since it is ANSI.
> 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