Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6832049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:48:41+00:00 2026-05-26T22:48:41+00:00

I am developing a small application using Struts, Spring and hibernate3. But now I

  • 0

I am developing a small application using Struts, Spring and hibernate3. But now I find trouble in executing named queries using HibernateTemplate.

Here is my entity class, Product.java

@Entity
@Table(name = "product")
@NamedQueries({
@NamedQuery(name = "Product.findAll", query = "SELECT p FROM Product p"),
@NamedQuery(name = "Product.findByProductid", query = "SELECT p FROM Product p WHERE p.productid = :productid"),
@NamedQuery(name = "Product.findByProductname", query = "SELECT p FROM Product p WHERE p.productname = :productname"),
@NamedQuery(name = "Product.findByProductdesc", query = "SELECT p FROM Product p WHERE p.productdesc = :productdesc"),
@NamedQuery(name = "Product.findByUnitprice", query = "SELECT p FROM Product p WHERE p.unitprice = :unitprice"),
@NamedQuery(name = "Product.findByStockquantity", query = "SELECT p FROM Product p WHERE p.stockquantity = :stockquantity")})
public class Product implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "productid")
private Integer productid;
@Basic(optional = false)
@Column(name = "productname")
private String productname;
@Column(name = "productdesc")
private String productdesc;
@Basic(optional = false)
@Column(name = "unitprice")
private double unitprice;
@Basic(optional = false)
@Column(name = "stockquantity")
private int stockquantity;

public Product() {
}

public Product(Integer productid) {
    this.productid = productid;
}

public Product(Integer productid, String productname, double unitprice, int stockquantity) {
    this.productid = productid;
    this.productname = productname;
    this.unitprice = unitprice;
    this.stockquantity = stockquantity;
}

public Integer getProductid() {
    return productid;
}

public void setProductid(Integer productid) {
    this.productid = productid;
}

public String getProductname() {
    return productname;
}

public void setProductname(String productname) {
    this.productname = productname;
}

public String getProductdesc() {
    return productdesc;
}

public void setProductdesc(String productdesc) {
    this.productdesc = productdesc;
}

public double getUnitprice() {
    return unitprice;
}

public void setUnitprice(double unitprice) {
    this.unitprice = unitprice;
}

public int getStockquantity() {
    return stockquantity;
}

public void setStockquantity(int stockquantity) {
    this.stockquantity = stockquantity;
}

@Override
public int hashCode() {
    int hash = 0;
    hash += (productid != null ? productid.hashCode() : 0);
    return hash;
}

@Override
public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof Product)) {
        return false;
    }
    Product other = (Product) object;
    if ((this.productid == null && other.productid != null) || (this.productid != null && !this.productid.equals(other.productid))) {
        return false;
    }
    return true;
}

@Override
public String toString() {
    return "com.pojo.Product[productid=" + productid + "]";
}

}

Here is the DAO, ProductDAO.java

public class ProductDAO extends HibernateDaoSupport{

public List listProducts() {
    return getHibernateTemplate().findByNamedQuery("Product.findAll");
}
}

But when I run the application, I am getting the following exception.

org.springframework.orm.hibernate3.HibernateSystemException: Named query not known: Product.findAll

There is already a method- findNamedQuery()- in HibernateTemplate class to run named queries. And the queries are entered as annotations.

Do I need to put that in the mapping file as well?

Any thoughts please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:48:41+00:00Added an answer on May 26, 2026 at 10:48 pm

    Did you remember to add the Product entity to the annotatedClasses?

    See here: http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/orm/hibernate3/annotation/AnnotationSessionFactoryBean.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing bunch of relatively small Spring based java web-application. I'm mostly using annotations
I am developing a small utility application emailafriend using Spring. The basic functionality is
I'm developing a small application using Blend, basically what I have in my application
I'm thinking of developing a small application using IronPython, however I want to distribute
I'm developing a small web application using Microsoft Silverlight 3. I'm using Microsoft Expressin
I am developing a small web application using cherrypy and I would like to
I'm about to start developing a small Windows application using Microsoft Visual C# 2008
I have question I'm developing small application to desktop in win Forms. I'm using
I am developing a small desktop application in JAVA using Netbeans. I place a
I am developing a small application in Java. I am using Java2D Library for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.