title: How to use Spring + Hibernate query for join table
body: <p>I using Spring MVC + Hibernate + MySql running on Tomcat with Intellij Editor</p>
  
  <p>I want to query HQL like MySql like this</p>
  
  <pre><code>SELECT * from Customer c LEFT JOIN Person p ON p.idPerson = c.idCustomer
  </code></pre>
  
  <p>It's not working it's return error like this</p>
  
  <pre><code>HTTP Status 500 - Request processing failed; nested exception is org.hibernate.hql.internal.ast.QuerySyntaxException: Path expected for join! [from com.springapp.mvc.model.Customer c LEFT JOIN Person p ON p.idPerson = c.idCustomer]
  </code></pre>
  
  <p>Here's my database</p>
  
  <pre><code>    CREATE TABLE `Customer` (
    `idCustomer` int(11) NOT NULL AUTO_INCREMENT,
    `name` varchar(45) DEFAULT NULL,
    PRIMARY KEY (`idCustomer`),
    CONSTRAINT `customer to person` FOREIGN KEY (`idCustomer`) REFERENCES `Person` (`idPerson`) ON DELETE NO ACTION ON UPDATE NO ACTION
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
      CREATE TABLE `Person` (
    `idPerson` int(11) NOT NULL AUTO_INCREMENT,
    `country` varchar(45) DEFAULT NULL,
    PRIMARY KEY (`idPerson`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  </code></pre>
  
  <p>Relationship is OneToOne from customer.idCustomer to person.idPerson</p>
  
  <p>Here's my code</p>
  
  <p>model.Customer.java</p>
  
  <pre><code>@Entity
  @Table(name = "Customer")
  public class Customer {
      private int idCustomer;
      private String name;
  
      @Id
      @Column(name = "idCustomer")
      public int getIdCustomer() {
          return idCustomer;
      }
  
      public void setIdCustomer(int idCustomer) {
          this.idCustomer = idCustomer;
      }
  
      @Basic
      @Column(name = "name")
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      @Override
      public boolean equals(Object o) {
          if (this == o) return true;
          if (o == null || getClass() != o.getClass()) return false;
  
          Customer customer = (Customer) o;
  
          if (idCustomer != customer.idCustomer) return false;
          if (name != null ? !name.equals(customer.name) : customer.name != null) return false;
  
          return true;
      }
  
      @Override
      public int hashCode() {
          int result = idCustomer;
          result = 31 * result + (name != null ? name.hashCode() : 0);
          return result;
      }
  }
  </code></pre>
  
  <p>model.Person.java</p>
  
  <pre><code>@Entity
  @Table(name = "Person")
  public class Person {
      private int idPerson;
      private String country;
  
      @Id
      @Column(name = "idPerson")
      public int getIdPerson() {
          return idPerson;
      }
  
      public void setIdPerson(int idPerson) {
          this.idPerson = idPerson;
      }
  
      @Basic
      @Column(name = "country")
      public String getCountry() {
          return country;
      }
  
      public void setCountry(String country) {
          this.country = country;
      }
  
      @Override
      public boolean equals(Object o) {
          if (this == o) return true;
          if (o == null || getClass() != o.getClass()) return false;
  
          Person person = (Person) o;
  
          if (idPerson != person.idPerson) return false;
          if (country != null ? !country.equals(person.country) : person.country != null) return false;
  
          return true;
      }
  
      @Override
      public int hashCode() {
          int result = idPerson;
          result = 31 * result + (country != null ? country.hashCode() : 0);
          return result;
      }
  }
  </code></pre>
  
  <p>and this my Implement
  dao.CustomerDAOImpl.java</p>
  
  <pre><code>public List&lt;Customer&gt; listCustomers() {
      Session session = this.sessionFactory.getCurrentSession();
      List&lt;Customer&gt; customersList = session.createQuery("from Customer c LEFT JOIN Person p ON p.idPerson = c.idCustomer").list();
  
      for (Customer c : customersList) {
          logger.info("Customer List::" + c);
      }
  
      return customersList;
  }
  </code></pre>
  
  <p>Im am new java developer and poor in english somebody please help me Thank you</p>