title: JPA entitymanager run native sql query to get everything out from a table
body: <p>What I need to do is to run a piece of native sql query to select everything and get 
  data out from a specific table.</p>
  
  <p>My app is a spring hibernate based web app. Here is my code:</p>
  
  <p>DAOserviceImpl:</p>
  
  <pre><code>@Service
  public class ItemServiceImpl implements ItemService {
  
      @PersistenceContext
      EntityManager em;
  
      @Transactional
      public void addItem(Item item) {
          em.persist(item);
      }
  
      @Transactional
      public List&lt;Item&gt; iosADVsearchResults(String itemCode) {
          //run native query with jpa
          List&lt;Item&gt; itemList = (List&lt;Item&gt;)em.createQuery("SELECT * FROM item itemcode='" + itemCode + "'")
              .getResultList(); 
          return itemList;
      }
  }
  </code></pre>
  
  <p>but what I eventually get is this error:</p>
  
  <blockquote>
    <p>HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: = near line 1, column 35 [SELECT itemcode FROM item itemcode='ll3369']</p>
  </blockquote>
  
  <p>I was following this tutorial: <a href="http://www.oracle.com/technetwork/articles/vasiliev-jpql-087123.html" rel="nofollow">http://www.oracle.com/technetwork/articles/vasiliev-jpql-087123.html</a></p>
  
  <p>Please help, any code example would be helpful.</p>