2

I am trying to do a simple inner join using GORM's executeQuery but getting a QuerySyntaxException.....I believe my hql is ok. Here is my query

def query = Institution.executeQuery("select longName from Institution inner join TacticalIndustryCode.idInstitution")
log.info(query.size())

I tried this with same error too:

def query = Institution.executeQuery("from Institution inner join TacticalIndustryCode.id")

Here is my exception that I am receiving

org.hibernate.hql.ast.QuerySyntaxException: Invalid path: 'null.idInstitution' [select longName from erebus.industryGroup.Institution inner join TacticalIndustryCode.idInstitution]
    at erebus.industryGroup.TacticalIndustryCodeController$$ENunaZiV.list(TacticalIndustryCodeController.groovy:20)
    at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
    at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
user1981882
  • 21
  • 1
  • 3

2 Answers2

1

Make sure you have a field called 'idInstitution' in the domain 'TacticalIndustryCode'.

Remember that when you write HQLs, you don't refer to the table or its columns. Instead you use the mapped class and their properties.

biniam
  • 8,099
  • 9
  • 49
  • 58
0
def query = Institution.executeQuery("select inst.longName from Institution as inst inner join inst.tacticalIndustryCode")

For more info follow the link: http://grails.asia/grails-hql-join-examples

Kundan Ray
  • 370
  • 1
  • 4
  • 15