Question : Hibernate Exception - Errors in named queries

Using Struts 1.3 , Hibernate 3 and Tomcat 5.5v

I have a stored procedure that gives values from multiple tables.

Java Class to get the data -->
                                   List list = null;
                     try
                  {
                  Session session = HibernateUtils.currentSession();
                                      Query query = session.getNamedQuery("SalesForecastSalesRepSummarySp");
                  query.setParameter("para1", marketID );
                  query.setParameter("para2", statusID );
                  query.setParameter("para3",quarterID);
                  query.setParameter("para4", month );
                  query.setParameter("para5",year );
                  query.setParameter("para6",customer );
                  query.setParameter("para7",loggedInUserID);

                  list = query.list();
                                    
                  HibernateUtils.closeSession();
                                    
                  }
            catch (Exception e) {
                        System.out.println(e);
                        }
            return list;



POJO (SalesForecast.java)
______________________

public class SalesForecast implements java.io.Serializable{
            
            private Short managerId;  
            private Short saleaRepId;  
            private Short totalPrice;
            private BigDecimal forecast;    
            private BigDecimal pending;    
            private BigDecimal booked;
            private BigDecimal lost;
            
            public SalesForecast()
            {
                  super();
            }
            public SalesForecast(Short managerId
                        , Short saleaRepId
                        , Short totalPrice
                        , BigDecimal forecast
                        , BigDecimal pending
                        , BigDecimal booked
                        ,BigDecimal lost)
            {
                  super();
                  this.managerId = managerId;
                  this.saleaRepId = saleaRepId;
                  this.totalPrice = totalPrice;
                  this.forecast = forecast;
                  this.pending = pending;
                  this.booked = booked;
                  this.lost=lost;
            }
            
            public Short getManagerId() {
                  return managerId;
            }
            public void setManagerId(Short managerId) {
                  this.managerId = managerId;
            }
            
            
            public Short getSaleaRepId() {
                  return saleaRepId;
            }

            public void setSaleaRepId(Short saleaRepId) {
                  this.saleaRepId = saleaRepId;
            }

            

            public Short getTotalPrice() {
                  return totalPrice;
            }

            public void setTotalPrice(Short totalPrice) {
                  this.totalPrice = totalPrice;
            }

            public BigDecimal getForecast() {
                  return forecast;
            }
            public void setForecast(BigDecimal forecast) {
                  this.forecast = forecast;
            }
            public BigDecimal getPending() {
                  return pending;
            }
            public void setPending(BigDecimal pending) {
                  this.pending = pending;
            }
            public BigDecimal getBooked() {
                  return booked;
            }
            public void setBooked(BigDecimal booked) {
                  this.booked = booked;
            }

            public BigDecimal getLost() {
                  return lost;
            }

            public void setLost(BigDecimal lost) {
                  this.lost = lost;
            }
            
}



SalesForecast.hbm.xml
___________________













 { ? = call SalesForecastSalesRepSummarySp(:para1, :para2, :para3, :para4, :para5, :para6, :para7) }




ERRORS-->

javax.servlet.ServletException: Filter execution threw an exception


root cause

java.lang.ExceptionInInitializerError
      com.cynosure.sf.utils.HibernateUtils.(HibernateUtils.java:22)
      com.cynosure.sf.service.impl.SecurityServiceImpl.authenticateUser(SecurityServiceImpl.java:28)
      com.cynosure.sf.security.SecurityFilterRealm.booleanAuthenticate(SecurityFilterRealm.java:14)
      org.securityfilter.realm.SimpleSecurityRealmBase.authenticate(SimpleSecurityRealmBase.java:107)
      org.securityfilter.authenticator.FormAuthenticator.processLogin(FormAuthenticator.java:178)
      org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java:138)


root cause

org.hibernate.HibernateException: Errors in named queries: dbo.SalesForecastSalesRepSummarySp
      org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:407)
      org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
      com.cynosure.sf.utils.HibernateUtils.(HibernateUtils.java:18)
      com.cynosure.sf.service.impl.SecurityServiceImpl.authenticateUser(SecurityServiceImpl.java:28)
      com.cynosure.sf.security.SecurityFilterRealm.booleanAuthenticate(SecurityFilterRealm.java:14)
      org.securityfilter.realm.SimpleSecurityRealmBase.authenticate(SimpleSecurityRealmBase.java:107)
      org.securityfilter.authenticator.FormAuthenticator.processLogin(FormAuthenticator.java:178)
      org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java:138)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.27 logs.


I have been trying to resolve it for a while. But cannot find way out. Any help will be appreciated. Thanks in Advance.

Answer : Hibernate Exception - Errors in named queries

Fixed it by setting up a class tag with reference to the POJO and matching the resultset to the elements in the domain class. Thanks for your response Friends.
Random Solutions  
 
programming4us programming4us