title: I want to fetch my product details in database but it throws excepion org.hibernate.hql.internal.ast.QuerySyntaxException: Product is not mapped
body: <p>I'm keep getting an exception. I've tried to solve this problem for a few days now...</p>
  
  <p>Please help me...</p>
  
  <pre><code>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.hql.internal.ast.QuerySyntaxException: Product is not mapped [from Product]
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:981)
  org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
  org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
  </code></pre>
  
  <p>This is my ProductController</p>
  
  <pre><code>package com.controller;
  
  import java.util.List;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.web.bind.annotation.ModelAttribute;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.servlet.ModelAndView;
  
  import com.model.Categories;
  import com.model.Product;
  import com.service.ProductService;
  
  @Controller
  public class ProductController {
  
  @Autowired
  private ProductService productService;
  
  // Getters and Setters
  
  public ProductService getProductService() {
      return productService;
  }
  
  public void setProductService(ProductService productService) {
      this.productService = productService;
  }
  
  // Request Mapping
  
  @RequestMapping("/getAllProducts")
  public ModelAndView getAllProducts() {
      List&lt;Product&gt; products = productService.getAllProducts();
      return new ModelAndView("productList", "products", products);
  }
  
  @RequestMapping("getProductById/{productId}")
  public ModelAndView getProductById(@PathVariable(value = "productId") String productId) {
      Product product = productService.getProductById(productId);
      return new ModelAndView("productPage", "productObj", product);
  }
  
  @RequestMapping("/delete/{productId}")
  public String deleteProduct(@PathVariable(value = "productId") String productId) {
      productService.deleteProduct(productId);
      return "redirect:/getAllProducts";
  }
  
  @RequestMapping(value = "/admin/product/addProduct", method = RequestMethod.GET)
  public String getProductForm(Model model) {
      Product product = new Product();
      Categories category = new Categories();
      category.setCategoryId("1");
      product.setProductCategory(category);
      model.addAttribute("productFormObj", product);
      return "productForm";
  }
  
  @RequestMapping(value = "/admin/product/addProduct", method = RequestMethod.POST)
  public String addProduct(@ModelAttribute(value = "productFormObj") Product product) {
      productService.addProduct(product);
      return "redirect:/getAllProducts";
  }
  
  }
  </code></pre>
  
  <p>This is my ProductClass</p>
  
  <pre><code>package com.model;
  
  import java.util.Locale.Category;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.JoinColumn;
  import javax.persistence.ManyToOne;
  import javax.persistence.Table;
  
  @Entity
  @Table(name = "product")
  public class Product {
  
  @Id
  @Column
  @GeneratedValue(strategy = GenerationType.AUTO)
  private String productId;
  @Column
  private String productDescription;
  @Column
  private String productManufacturer;
  @Column
  private String productName;
  @Column
  private double productPrice;
  @Column(name="stockunit")
  private String unitStock;
  @ManyToOne
  @JoinColumn(name="categoryId")
  private Categories productCategory;
  
  //  Getters and Setter
  
  public String getProductId() {
      return productId;
  }
  
  public Categories getProductCategory() {
      return productCategory;
  }
  
  public String getProductDescription() {
      return productDescription;
  }
  
  public String getProductManufacturer() {
      return productManufacturer;
  }
  
  public String getProductName() {
      return productName;
  }
  
  public double getProductPrice() {
      return productPrice;
  }
  
  public String getUnitStock() {
      return unitStock;
  }
  
  public void setProductId(String productId) {
      this.productId = productId;
  }
  
  public void setProductCategory(Categories category) {
      this.productCategory = category;
  }
  
  public void setProductDescription(String productDescription) {
      this.productDescription = productDescription;
  }
  
  public void setProductManufacturer(String productManufacturer) {
      this.productManufacturer = productManufacturer;
  }
  
  public void setProductName(String productName) {
      this.productName = productName;
  }
  
  public void setProductPrice(double productPrice) {
      this.productPrice = productPrice;
  }
  
  public void setUnitStock(String unitStock) {
      this.unitStock = unitStock;
  }
  
  //Constructors
  public Product(String productId, Categories productCategory, String       productDescription, String productManufacturer,
          String productName, double productPrice, String unitStock) {
      super();
      this.productId = productId;
      this.productCategory = productCategory;
      this.productDescription = productDescription;
      this.productManufacturer = productManufacturer;
      this.productName = productName;
      this.productPrice = productPrice;
      this.unitStock = unitStock;
  }
  public Product(){
  
  }   
  }
  </code></pre>
  
  <p>This is my application Context</p>
  
  <pre><code>&lt;!-- for Entity Classes annotated Classes package --&gt;
      &lt;property name="packagesToScan"&gt;
          &lt;list&gt;
              &lt;value&gt;com.model.Product&lt;/value&gt;
              &lt;value&gt;com.model.Categories&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>My Category Class</p>
  
  <pre><code>import java.util.List;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.Id;
  import javax.persistence.OneToMany;
  import javax.persistence.Table;
  
  @Entity
  @Table(name = "categories")
  public class Categories {
  
  @Id
  private String categoryId;
  @Column
  private String Categories;
  @OneToMany(mappedBy = "categories")
  private List&lt;Product&gt; product;
  
  //And Respective Getters and Setters
  </code></pre>
  
  <p>ProductList page</p>
  
  <pre><code>&lt;tbody&gt;
              &lt;c:forEach items="${products}" var="prod"&gt;
              &lt;tr&gt;
              &lt;td&gt;${prod.productId}&lt;/td&gt;
              &lt;td&gt;${prod.productCategory}&lt;/td&gt;
              &lt;td&gt;${prod.productName}&lt;/td&gt;
              &lt;td&gt;${prod.productPrice}&lt;/td&gt;
              &lt;td&gt;${prod.unitStock}&lt;/td&gt;
              &lt;td&gt;${prod.productDescription}&lt;/td&gt;
              &lt;td&gt;${prod.productManufacturer}&lt;/td&gt;
              &lt;td&gt;
              &lt;a href="getProductById/${prod.productId}"&gt;&lt;span   class="glyphicon glyphicon-info"&gt;&lt;/span&gt;&lt;/a&gt;
              &lt;a href="delete/${prod.productId}"&gt;&lt;span class="glyphicon glyphicon-trash"&gt;&lt;/span&gt;&lt;/a&gt;
              &lt;/td&gt;
              &lt;/tr&gt;
              &lt;/c:forEach&gt;
  </code></pre>