Project
IntelliJ IDEA
Priority
Normal
Type
Bug
Fix versions
No Fix versions
State
Fixed
Assignee
Gregory Shrago
Subsystem
Editor. Error Highlighting
Affected versions
No Affected versions
Fixed in build
108.65  
  • Created by   R Toomey
    2 years ago (14 May 2009 01:44)
  • Updated by   Evgeniy Schepotiev
    21 months ago (27 Apr 2010 16:30)
  • Jira: IDEADEV-37043
    (history, comments)
 
IDEA-48988 Reversion: HQL syntax editor now gets upset by ternary condition
0
Issue is visible to: All Users
  The issue is visible to the selected user group only
I have an Idea project with a Spring facet and a Hibernate facet. There is no JPA facet in the project.

Idea's Persistence QL inspection now highlights red both outcomes of a ternary condition, which seems to be a reversion, because this was working fine in build 9732.

h4. No longer working

This code snippet would be highlighted red at both outcomes "and f.effectiveDate .... If you mouse over, the error condition tooltip is FROM expected (e.g. FROM <variable_declartions>).
Query q = getSession().createQuery("select sum(f.value) " +
                "from Foo f, Bar b " +
                "where f.bar.id = :barId " +
                (excludeEndDate ?
                        "and f.effectiveDate <= b.dataDate and (f.inactiveDate > b.dataDate or f.inactiveDate is null) "
                        : "and f.effectiveDate < b.dataDate and (f.inactiveDate >= b.dataDate or f.inactiveDate is null) ") +
                "and f.value is not null");


h4. Curious behaviour

If you extract the offending ternary condition as a string, the HQL syntax error highlight goes away (just the benefit of the doubt?):
String s = (excludeEndDate ?
                        "and f.effectiveDate <= b.dataDate and (f.inactiveDate > b.dataDate or f.inactiveDate is null) "
                        : "and f.effectiveDate < b.dataDate and (f.inactiveDate >= b.dataDate or f.inactiveDate is null) ");

Query q = getSession().createQuery("select sum(f.value) " +
                "from Foo f, Bar b " +
                "where f.bar.id = :barId " +
                s +
                "and f.value is not null");


h4. Workaround

The only workaround I could find was to extract the offending ternary condition to a String. Otherwise, this error _cannot_ be silenced, not even with //noinspection [something].

Environment: Idea 8.1.1 on Windows XP
Spring 2.5.6 / Hibernate 3.2.6 GA - project has Spring and Hibernate facets but no JPA facet

Issue was resolved
Comments (0)
 
History
 
Linked Issues (?)
 
Issue has no comments