title: JPQL createNativeQuery with join failing
body: <p>I'm joining 2 entities with a foreign key relationship in the db, but not in the code (saving the why for another question):</p>
  
  <pre><code>em.createNativeQuery("SELECT u.* FROM user u JOIN user_community_organization uco ON "
                  + "u.user_id = uco.user_id "
                  + "WHERE uco.community_id = :communityId "
                  + "AND lower(u.email) = :email", User.class)
                  .setParameter("communityId", communityId)
                  .setParameter("email", email.toLowerCase());
  </code></pre>
  
  <p>But the query fails during runtime with:</p>
  
  <pre><code>Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 
  You have an error in your SQL syntax; check the manual that corresponds  to your MySQL 
  server version for the right syntax to use near ':communityId AND 
  lower(u.email) = :email' at line 1
  Error Code: 1064
  Call: SELECT u.* FROM user u JOIN user_community_organization uco ON  
  u.user_id = uco.user_id WHERE uco.community_id = :communityId AND lower(u.email) = :email
  </code></pre>
  
  <p>I've tried different variations, moving the parameters in and out of the ON bit, removing lower. Nothing works.</p>
  
  <p>Before I added the join:</p>
  
  <pre><code>em.createQuery("select object(o) from User as o where lower(o.email) = :email");
          q.setParameter("email", email.toLowerCase());
  </code></pre>
  
  <p>This query worked fine.</p>
  
  <p>What am I doing wrong?
  Running on GlassFish3.1, toplink and mySql.</p>