title: hibernate.jpa.criteria.BasicPathUsageException: Cannot join to attribute of basic type
body: <p>I have two tables: <code>Tax</code> and <code>TaxRule</code>. There is one column same in both table i.e <code>TAX_RULE_ID</code>. But don't have any Hibernate mapping like <code>OneToOne</code> or <code>OneToMany</code>. Both table looks like-</p>
  
  <p><strong>TAX</strong></p>
  
  <pre><code>@Id
  @Column(name = "TAX_RATE_ID")
  private Long taxRateId;
  
  @Column(name = "TAX_RULE_ID")
  private Long taxRuleId;
  
  @Column(name = "TAX_TYPE")
  private String taxType;
  </code></pre>
  
  <p><strong>TAX_RULE</strong></p>
  
  <pre><code>@Id
  @Column(name = "TAX_RULE_ID")
  private Long taxRuleId;
  
  @Column(name = "TAX_CD")
  private String TaxCode;
  
  @Column(name = "STATE")
  private String state;
  </code></pre>
  
  <p>I am trying to fetch data on the key i.e <code>TAX_RULE_ID</code>. This column is common in both table.
  I have following <code>Hibernate</code> code in which I am joining both table on the <code>TAX_RULE_ID</code> column as follows:</p>
  
  <pre><code>CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
  CriteriaQuery&lt;String[]&gt; cQuery =        criteriaBuilder.createQuery(String[].class);
  Root&lt;Tax&gt; taxRoot = cQuery.from(Tax.class);
  
  cQuery.multiselect(taxRateRoot.get("taxType"), taxRateRoot.get("taxRate"));
  List&lt;Predicate&gt; predicates = new ArrayList&lt;&gt;();
  Join&lt;Tax, TaxRule&gt; join = taxRoot.join("taxRuleId"); 
  .....rest of the code.
  </code></pre>
  
  <p>I am getting following Exception on the join point:</p>
  
  <pre><code>org.hibernate.jpa.criteria.BasicPathUsageException: Cannot join to attribute of basic type
  at   org.hibernate.jpa.criteria.path.AbstractFromImpl.constructJoin(AbstractFromImpl.java:270)
  at org.hibernate.jpa.criteria.path.AbstractFromImpl.join(AbstractFromImpl.java:263)
  at org.hibernate.jpa.criteria.path.AbstractFromImpl.join(AbstractFromImpl.java:436)
  at com.iclsystems.base.dao.TaxRateDAOImpl.getTaxTypeForApplicableWorkOrderTax(TaxRateDAOImpl.java:31)
  at com.iclsystems.base.businessObjects.TaxLookupBOImpl.getTaxTypeForApplicableWorkOrderTax(TaxLookupBOImpl.java:53)
  at com.iclsystems.base.businessObjects.TaxLookupBOImpl.getWorkOrderTaxLookup(TaxLookupBOImpl.java:29)
  at com.iclsystems.test.eventhandler.base.TaxLookupBOTest.testTaxLookupBO(TaxLookupBOTest.java:52)
  </code></pre>