Hi,
I'm using Hibernate 3.2, and I'm getting a java.lang.IllegalArgumentException, while trying to set a Long parameter of a query.
I'm using UserTransaction API directly to control my transaction, so I'm not calling openSession() and session.close(). I'm assuming that the session is opened when I start the transaction and that it is closed when I commit or rollback the transaction.
The problem occurs when the line "query.setLong(...)" of the method selectByFolder (see code below) is executed. The method selectByFolder belongs to one of my DAO classes:
Code:
public List selectByFolder(Key folder) throws InfraException {
List list = new ArrayList();
final String voClassName = this.getVOClass().getName();
Session session = hibernateUtil.currentSession();
try {
String hql = "select i from "
+ voClassName + " as i where "
+ "i.folder.id = :id and i.deleted = 'false'";
Query query = session.createQuery(hql);
query.setLong("id", folder.getId().longValue());
list = query.list();
...
} catch (Exception e) {
...
}
return list;
}
Here is the full stackTrace of the exception I'm getting:
java.lang.IllegalArgumentException: Parameter id does not exist as a named parameter in
[select i from br.fapesp.tidia.ae.common.portfolio.commontypes.vo.PortfolioItemVO as i
where i.folder.id = :id and i.deleted = 'false']
at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:349)
at org.hibernate.impl.AbstractQueryImpl.setLong(AbstractQueryImpl.java:594)
at br.fapesp.tidia.ae.infra.portfolio.db.impl.HibernateItemDAO.selectByFolder(HibernateItemDAO.java:179)
at br.fapesp.tidia.ae.elearning.portfolio.itemmgr.impl.ItemMgrComponent.calculateNewItemNumber(ItemMgrComponent.java:1125)
at br.fapesp.tidia.ae.elearning.portfolio.itemmgr.impl.ItemMgrComponent.createPortfolioItem(ItemMgrComponent.java:235)
at br.fapesp.tidia.ae.system.portfolio.portfolioSystem.impl.PortfolioSystemComponent.createPortfolioItem(PortfolioSystemComponent.java:388)
at br.fapesp.tidia.ae.presentation.portfolio.action.CreatePortfolioItemAction.createPortfolioItem(CreatePortfolioItemAction.java:189)
at br.fapesp.tidia.ae.presentation.portfolio.action.CreatePortfolioItemAction.execute(CreatePortfolioItemAction.java:136)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Thread.java:595)
ERROR: Parameter id does not exist as a named parameter in [select i from br.fap
esp.tidia.ae.common.portfolio.commontypes.vo.PortfolioItemVO as i where i.folder
.id = :id and i.deleted = 'false'] (2008-05-13 13:14:02,406 http-8080-Processor2
3_root)
Could anybody help me to undertsand what can be causing this exception?
Thanks in advance for any help,
Cristina