Hi All
Can someone please have a look at this query, I can not understand the error. All I'm trying to do is select all manufacturers from Product table with DISTINCT clause. The Product table has an attribute called 'String manufacturer' . Why am I getting this error ???
Code:
@NamedQuery(name = "Product.findByManu", query = "SELECT DISTINCT p.manufacturer FROM Product p WHERE p.categoryId.categoryId = :categoryId")
Query Manager
Code:
public List<Product> getProductsByManu(Integer categoryId) {
      em.getTransaction().begin();
      List<Product> prods = em.createNamedQuery("Product.findByManu")
            .setParameter("categoryId", categoryId).getResultList();
      em.getTransaction().commit();
      return prods;
   }
Error
Code:
javax.servlet.ServletException: The class 'java.lang.String' does not have the property 'manufacturer'.
Many thanks
Zed