title: Issue with a JPA query
body: <p>I am trying to execute the following JPA query:</p>
  
  <pre><code>    public static final String UPDATE_INVENTORY_CUSTOMER_FOR_AMS_MAPPING = "UPDATE Inventory inventory SET" 
      + " inventory.customer.id = :" + DataAccessConstants.PARAM_CUSTOMER_ID
      + " ,inventory.lastUpdateUserId = :" + DataAccessConstants.PARAM_USER_ID
      + " where inventory.amsConsignorName = :" + DataAccessConstants.PARAM_AMS_CONSIGNOR_NAME
      + " and inventory.amsConsignorOrgCd = :" + DataAccessConstants.PARAM_AMS_CONSIGNOR_ORG_CD
      + " and inventory.amsConsignorTypeName = :" + DataAccessConstants.PARAM_AMS_CONSIGNOR_TYPE
      + " and inventory.status.code in (:" + DataAccessConstants.PARAM_STATUS + ")";  
  </code></pre>
  
  <p>but it is seeing the following:</p>
  
  <pre><code>update ATL_INVENTORY,  set CONSIGNOR_ID=?, LAST_UPDATE_USER_ID=? where AMS_CONSIGNOR_NAME=? and AMS_CONSIGNOR_ORG_CD=? and AMS_CONSIGNOR_TYPE_NAME=? and (CODE in (? , ? , ? , ?))
  </code></pre>
  
  <p>Any ideal as to why there is a comma after the table name?</p>
  
  <hr>
  
  <p><strong>Solution</strong></p>
  
  <p>I had to change the original query to the following:</p>
  
  <pre><code>update Inventory inv set " 
      + "inv.customer.id = :" + DataAccessConstants.PARAM_CUSTOMER_ID + " "
      + "where inv.amsConsignorName =:" + DataAccessConstants.PARAM_AMS_CONSIGNOR_NAME + " "
      + "and inv.amsConsignorOrgCd =:" + DataAccessConstants.PARAM_AMS_CONSIGNOR_ORG_CD + " "
      + "and inv.amsConsignorTypeName =:" + DataAccessConstants.PARAM_AMS_CONSIGNOR_TYPE + " "
      + "and exists(select 1 from Code code where inv.status = code and code.code in (:" + DataAccessConstants.PARAM_STATUS + "))
  </code></pre>
  
  <p>Which then produced this:</p>
  
  <pre><code>update ATL_INVENTORY set CONSIGNOR_ID=? where AMS_CONSIGNOR_NAME=? and AMS_CONSIGNOR_ORG_CD=? and AMS_CONSIGNOR_TYPE_NAME=? and (exists (select 1 from ATL_CODE code1_ where ATL_INVENTORY.STATUS=CODE_ID and (code1_.CODE in (? , ? , ? , ?))))
  </code></pre>
  
  <p>Based on a clarification located here: <a href="http://opensource.atlassian.com/projects/hibernate/browse/HHH-2408" rel="nofollow noreferrer">Incorrect SQL generated for JPA QL Update statement involving multiple entities</a></p>