0

I have a query in hibernate to get list of items as below:

public List<ToDo> getItemsWithStatus(String status) {
    TypedQuery<ToDo> query = em.createQuery(
            "SELECT u FROM TODO u WHERE u.status LIKE :status ORDER BY u.id", ToDo.class);
    return query.getResultList();
}

But while executing the method, I'm getting this exception:

org.hibernate.hql.internal.ast.QuerySyntaxException: TODO is not mapped [SELECT u FROM TODO u WHERE u.status LIKE :status ORDER BY u.id]

Thanks Jithesh

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

4

Your entity class is named ToDo, but in your JPQL you are using TODO (notice the difference in cases).

Rafal G.
  • 4,252
  • 1
  • 25
  • 41
  • I have updated the JPQL, and successfully created the query object. But while executing the query getting the below exception org.hibernate.QueryException: Not all named parameters have been set: [status] [SELECT u FROM ToDo u WHERE u.status LIKE :status ORDER BY u.id] – Jithesh Gopinathan Oct 13 '17 at 18:15
  • https://stackoverflow.com/questions/5983321/how-to-specify-a-jpa-named-parameter-surrounded-by-wildcards – Rafal G. Oct 13 '17 at 18:20