title: inner join is not working in hql in hibernate
body: <p>I want to fetch data from two tables using inner joins in HQL in hibernate but its not working don't know why??
  The Pojo classes and their mapping files are given:</p>
  
  <pre><code>public class Org  implements java.io.Serializable {
  
  
       private String quarter;
       private Orgtype orgtype;
       private String parent;
       private Set regions = new HashSet(0);
       private Set cfgOrgObjects = new HashSet(0);
  
      public Org() {
      }
  
  
      public Org(String quarter, Orgtype orgtype, String parent) {
          this.quarter = quarter;
          this.orgtype = orgtype;
          this.parent = parent;
      }
      public Org(String quarter, Orgtype orgtype, String parent, Set regions, Set cfgOrgObjects) {
         this.quarter = quarter;
         this.orgtype = orgtype;
         this.parent = parent;
         this.regions = regions;
         this.cfgOrgObjects = cfgOrgObjects;
      }
  
      public String getQuarter() {
          return this.quarter;
      }
  
      public void setQuarter(String quarter) {
          this.quarter = quarter;
      }
      public Orgtype getOrgtype() {
          return this.orgtype;
      }
  
      public void setOrgtype(Orgtype orgtype) {
          this.orgtype = orgtype;
      }
      public String getParent() {
          return this.parent;
      }
  
      public void setParent(String parent) {
          this.parent = parent;
      }
  }
  </code></pre>
  
  <p>Orgtype pojo class:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"&gt;
  &lt;!-- Generated Feb 4, 2015 2:30:35 AM by Hibernate Tools 3.6.0 --&gt;
  &lt;hibernate-mapping&gt;
      &lt;class name="pojo.Org" table="ORG" schema="myschema"&gt;
          &lt;id name="quarter" type="string"&gt;
              &lt;column name="QUARTER" length="600" /&gt;
              &lt;generator class="assigned" /&gt;
          &lt;/id&gt;
          &lt;many-to-one name="orgtype" class="pojo.Orgtype" fetch="select"&gt;
              &lt;column name="TYPE" length="30" not-null="true" /&gt;
          &lt;/many-to-one&gt;
          &lt;property name="parent" type="string"&gt;
              &lt;column name="PARENT" length="30" not-null="true" /&gt;
          &lt;/property&gt;
   &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>Mapping file for Orgtype table</p>
  
  <pre><code>public class Orgtype implements java.io.Serializable {
  
      private String type;
      private String description;
  //    private Set orgs = new HashSet(0);
      private Set&lt;Org&gt; orgs = new HashSet&lt;Org&gt;();
  
      public Orgtype() {
      }
  
      public Orgtype(String type, String description) {
          this.type = type;
          this.description = description;
      }
  
      public Orgtype(String type, String description, Set orgs) {
          this.type = type;
          this.description = description;
          this.orgs = orgs;
      }
  
      public String getType() {
          return this.type;
      }
  
      public void setType(String type) {
          this.type = type;
      }
  
      public String getDescription() {
          return this.description;
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
      public Set getOrgs() {
          return this.orgs;
      }
  
      public void setOrgs(Set orgs) {
          this.orgs = orgs;
      }
  
  }
  </code></pre>
  
  <p>Orgtype mapping file:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"&gt;
  &lt;!-- Generated Feb 4, 2015 2:30:35 AM by Hibernate Tools 3.6.0 --&gt;
  &lt;hibernate-mapping&gt;
      &lt;class name="pojo.Orgtype" table="ORGTYPE" schema="myschema"&gt;
          &lt;id name="type" type="string"&gt;
              &lt;column name="TYPE" length="30" /&gt;
              &lt;generator class="assigned" /&gt;
          &lt;/id&gt;
          &lt;property name="description" type="string"&gt;
              &lt;column name="DESCRIPTION" length="600" not-null="true" /&gt;
          &lt;/property&gt;
          &lt;set name="orgs" table="ORG" inverse="true" lazy="true" fetch="select"&gt;
              &lt;key&gt;
                  &lt;column name="TYPE" length="30" not-null="true" /&gt;
              &lt;/key&gt;
              &lt;one-to-many class="pojo.Org" /&gt;
          &lt;/set&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>and query i am using is :</p>
  
  <pre><code> Query q = sess.createQuery("SELECT og.quarter,og.parent,ogt.type,ogt.description FROM Org og INNER JOIN Orgtype ogt ogt.type = og.Orgtype" );
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>ERROR:   line 1:94: unexpected token: ogt
  ERROR:   line 1:94: unexpected token: ogt
  line 1:94: unexpected token: ogt
      at org.hibernate.hql.internal.antlr.HqlBaseParser.fromJoin(HqlBaseParser.java:1694)
      at org.hibernate.hql.internal.antlr.HqlBaseParser.fromClause(HqlBaseParser.java:1349)
      at org.hibernate.hql.internal.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:1055)
      at org.hibernate.hql.internal.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:701)
      at org.hibernate.hql.internal.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:294)
      at org.hibernate.hql.internal.antlr.HqlBaseParser.statement(HqlBaseParser.java:157)
      at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:268)
      at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:182)
      at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138)
      at org.hibernate.engine.query.spi.HQLQueryPlan.&lt;init&gt;(HQLQueryPlan.java:105)
      at org.hibernate.engine.query.spi.HQLQueryPlan.&lt;init&gt;(HQLQueryPlan.java:80)
      at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168)
      at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:221)
      at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:199)
      at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1778)
      at managedBean.ManagedBean.insertf(ManagedBean.java:140)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.sun.el.parser.AstValue.invoke(AstValue.java:275)
      at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
      at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
      at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:147)
      at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
      at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:818)
      at javax.faces.component.UICommand.broadcast(UICommand.java:300)
      at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
      at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
      at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
      at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
      at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
      at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
      at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
      at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
      at java.lang.Thread.run(Thread.java:744)
  </code></pre>