Microsoft
Software
Hardware
Network
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.currentSess
ion();
Query query = session.getNamedQuery("Sal
esForecast
SalesRepSu
mmarySp");
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"
,loggedInU
serID);
list = query.list();
HibernateUtils.closeSessio
n();
}
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 SalesForecastSalesRepSumma
rySp(:para
1, :para2, :para3, :para4, :para5, :para6, :para7) }
ERRORS-->
javax.servlet.ServletExcep
tion: Filter execution threw an exception
root cause
java.lang.ExceptionInIniti
alizerErro
r
com.cynosure.sf.utils.Hibe
rnateUtils
.
(
HibernateU
tils.java:
22)
com.cynosure.sf.service.im
pl.Securit
yServiceIm
pl.authent
icateUser(
SecuritySe
rviceImpl.
java:28)
com.cynosure.sf.security.S
ecurityFil
terRealm.b
ooleanAuth
enticate(S
ecurityFil
terRealm.j
ava:14)
org.securityfilter.realm.S
impleSecur
ityRealmBa
se.authent
icate(Simp
leSecurity
RealmBase.
java:107)
org.securityfilter.authent
icator.For
mAuthentic
ator.proce
ssLogin(Fo
rmAuthenti
cator.java
:178)
org.securityfilter.filter.
SecurityFi
lter.doFil
ter(Securi
tyFilter.j
ava:138)
root cause
org.hibernate.HibernateExc
eption: Errors in named queries: dbo.SalesForecastSalesRepS
ummarySp
org.hibernate.impl.Session
FactoryImp
l.
(S
essionFact
oryImpl.ja
va:407)
org.hibernate.cfg.Configur
ation.buil
dSessionFa
ctory(Conf
iguration.
java:1341)
com.cynosure.sf.utils.Hibe
rnateUtils
.
(
HibernateU
tils.java:
18)
com.cynosure.sf.service.im
pl.Securit
yServiceIm
pl.authent
icateUser(
SecuritySe
rviceImpl.
java:28)
com.cynosure.sf.security.S
ecurityFil
terRealm.b
ooleanAuth
enticate(S
ecurityFil
terRealm.j
ava:14)
org.securityfilter.realm.S
impleSecur
ityRealmBa
se.authent
icate(Simp
leSecurity
RealmBase.
java:107)
org.securityfilter.authent
icator.For
mAuthentic
ator.proce
ssLogin(Fo
rmAuthenti
cator.java
:178)
org.securityfilter.filter.
SecurityFi
lter.doFil
ter(Securi
tyFilter.j
ava: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
How to Restart the IIS in Local System in Windows XP
split column
Best way to package upgrades in Access
Access a SBS 2003 remotely via Remote Desktop gives a Logon Error.
Populate missing values in specific Excel worksheet and import into Access
DataGrid Drag and Drop Rows
One to one relationship Access 2003 and a dlookup
Help with GPEDIT.MSC
Custom Built Login Page to replace IIS Basic Authentication Popup
Convert/Compile Excel Sheets to Portable EXE