title: Querydsl join on same table multiple times
body: <p>Let's say I have two tables <code>Task</code> and <code>Company</code>. <code>Company</code> has columns <code>id</code> and <code>name</code>. <code>Task</code> has two columns <code>customerId</code> and <code>providerId</code> which link back to the <code>id</code> column for <code>Company</code>.</p>
  
  <p>Using Querydsl how do I join on the <code>Company</code> table twice so I can get the <code>name</code> for each company specified by the <code>customerId</code> and <code>providerId</code>?</p>
  
  <p>Code that maybe explains better what I'm trying:</p>
  
  <pre><code>Configuration configuration = new Configuration(templates);
  JPASQLQuery query = new JPASQLQuery(this.entityManager, configuration);
  
  QTask task = QTask.task;
  QCompany customer = QCompany.company;
  QCompany provider = QCompany.company;
  
  JPASQLQuery sql = query.from(task).join(customer).on(customer.id.eq(task.customerId))
      .join(provider).on(provider.id.eq(task.providerId));
  
  return sql.list(task.id, customer.name.as("customerName"), provider.name.as("providerName"));
  </code></pre>
  
  <p>Which generates SQL:</p>
  
  <pre><code>select task.id, company.name as customerName, company.name as providerName from task join company on company.id = task.customerId
  </code></pre>
  
  <p>And I'd really like it to be:</p>
  
  <pre><code>select task.id, customer.name as customerName, provider.name as providerName from task join company as customer on customer.id = task.customerId join company as provider on provider.id = task.providerId
  </code></pre>
  
  <p>I couldn't figure out how to alias the table I was joining so I could distinguish between customer and provider names. I tried doing <code>new QCompany("company as provider")</code> but that didn't work. Anyone know how one can do this?</p>