HQL language injection using grails domain class - can not detect entity

In a grail project, I'm trying to use the very great feature 'language injection' to have compile time syntax checking in my HQL.
I was happily using this feature with plain old java and Hibernate, but with grails it is not fully working.

I have a grails domain object named PresencePeriod and here is a test HQL statement:

        def query = """FROM PresencePeriod p WHERE :effectiveDate between p.startDate and p.endDate
                AND p.presenceCalendar.personId = :pid
                AND :effectiveDate between p.presenceCalendar.startDate and p.presenceCalendar.endDate"""

        def params = [pid: pid, effectiveDate: effectiveDate]
        def result = PresencePeriod.executeQuery(query, params) // caution: result will be a List of one element

I managed to configure the language injection for  PresencePeriod.executeQuery, and now I have syntax highlighting enabled on the HQL fragment, but Intellij is telling me that PresencePeriod is not an entity...
I have tried to add all available Entity annotations to PresencePeriod:

@org.hibernate.annotations.Entity
@grails.persistence.Entity
@javax.persistence.Entity
@DTO(targetPackage="cern.lms2.client.dto", defaultDisplayLabel="id")
class PresencePeriod {

...

}

but this is not working.

Is their any way to tell Idea that PresencePeriod is an entity for using in HQL ?


(I can't find how to format the code, I'll appreciate any help on this topic)

1 comment
Comment actions Permalink

This should be properly implemented in IDEA 11.
See: http://youtrack.jetbrains.net/issue/IDEA-71660

Cheers,
Taras

0

Please sign in to leave a comment.