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.
My app is a spring hibernate based web app. Here is my code:
DAOserviceImpl:
@Service public class ItemServiceImpl implements ItemService { @PersistenceContext EntityManager em; @Transactional public void addItem(Item item) { em.persist(item); } @Transactional public List<Item> iosADVsearchResults(String itemCode) { //run native query with jpa List<Item> itemList = (List<Item>)em.createQuery("SELECT * FROM item itemcode='" + itemCode + "'") .getResultList(); return itemList; } } but what I eventually get is this error:
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']
I was following this tutorial: http://www.oracle.com/technetwork/articles/vasiliev-jpql-087123.html
Please help, any code example would be helpful.