Hi,
I want to perform an SQL query that uses a logical and... Consequently i need to pass 2 parameters. How can i do that??
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
String uid_str = Integer.toString(uid);
String uid_allias = uid_str;
String mid_str = Integer.toString(mid);
String mid_allias = mid_str;
String query = "SELECT prediction "
+ "FROM prediction IN CLASS hu.bme.iit.charalambos.modules.actions.portlets.Prediction "
+ "WHERE prediction.UserID=:uid_allias && prediction.MatchupID=:mid_allias;";
Configuration cfg = new Configuration().addClass(Prediction.class);
SessionFactory sf = cfg.buildSessionFactory();
Session sess = sf.openSession();
//List list = sess.find(query);
List list = sess.find(query,uid_str,Hibernate.STRING);
if (list.size()>1)
{
return true;
}
else
return true;
Full stack trace of any exception that occurs:
java.sql.SQLException: No value specified for parameter 2
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2296)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2249)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1542)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1544)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1521)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1517)
at hu.bme.iit.charalambos.modules.actions.portlets.Util.CheckUIDPrediction(Util.java:203)
at hu.bme.iit.charalambos.modules.actions.portlets.Util.predict(Util.java:130)
at hu.bme.iit.charalambos.modules.actions.portlets.PredictionAction.buildNormalContext(PredictionAction.java:96)
at org.apache.jetspeed.modules.actions.portlets.VelocityPortletAction.buildNormalContext(VelocityPortletAction.java:74)
at org.apache.jetspeed.modules.actions.portlets.GenericMVCAction.doPerform(GenericMVCAction.java:169)
at org.apache.jetspeed.modules.actions.portlets.GenericMVCAction.perform(GenericMVCAction.java:76)
at org.apache.turbine.modules.ActionLoader.exec(ActionLoader.java:122)
at org.apache.jetspeed.portal.portlets.GenericMVCPortlet.buildContent(GenericMVCPortlet.java:276)
at org.apache.jetspeed.portal.portlets.GenericMVCPortlet.getContent(GenericMVCPortlet.java:207)
at org.apache.jetspeed.portal.security.portlets.PortletWrapper.getContent(PortletWrapper.java:119)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:260)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:207)
at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:250)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:94)
at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:109)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:94)
at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:109)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:271)
at org.apache.velocity.Template.merge(Template.java:296)
at org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:492)
at org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:461)
at org.apache.turbine.services.velocity.TurbineVelocityService.decodeRequest(TurbineVelocityService.java:494)
at org.apache.turbine.services.velocity.TurbineVelocityService.handleRequest(TurbineVelocityService.java:336)
at org.apache.turbine.services.velocity.TurbineVelocity.handleRequest(TurbineVelocity.java:143)
at org.apache.jetspeed.portal.controls.VelocityPortletControl.getContent(VelocityPortletControl.java:155)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:260)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:207)
at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:250)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:94)
at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:344)
at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:153)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:94)
at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:344)
at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:153)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:271)
at org.apache.velocity.Template.merge(Template.java:296)
at org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:492)
at org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:461)
at org.apache.turbine.services.velocity.TurbineVelocityService.decodeRequest(TurbineVelocityService.java:494)
at org.apache.turbine.services.velocity.TurbineVelocityService.handleRequest(TurbineVelocityService.java:336)
at org.apache.turbine.services.velocity.TurbineVelocity.handleRequest(TurbineVelocity.java:143)
at org.apache.jetspeed.portal.controllers.VelocityPortletController.getContent(VelocityPortletController.java:105)
at org.apache.jetspeed.portal.BasePortletSet.getContent(BasePortletSet.java:353)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:260)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:207)
at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:250)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:271)
at org.apache.velocity.Template.merge(Template.java:296)
at org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:492)
at org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:461)
at org.apache.turbine.services.velocity.TurbineVelocityService.decodeRequest(TurbineVelocityService.java:494)
at org.apache.turbine.services.velocity.TurbineVelocityService.handleRequest(TurbineVelocityService.java:336)
at org.apache.turbine.services.velocity.TurbineVelocity.handleRequest(TurbineVelocity.java:143)
at org.apache.jetspeed.portal.controllers.VelocityPortletController.getContent(VelocityPortletController.java:105)
at org.apache.jetspeed.portal.BasePortletSet.getContent(BasePortletSet.java:353)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:260)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:207)
at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:250)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:94)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:271)
at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:128)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:94)
at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:109)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:271)
at org.apache.velocity.Template.merge(Template.java:296)
at org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:492)
at org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:461)
at org.apache.turbine.services.velocity.TurbineVelocityService.decodeRequest(TurbineVelocityService.java:494)
at org.apache.turbine.services.velocity.TurbineVelocityService.handleRequest(TurbineVelocityService.java:336)
at org.apache.turbine.services.velocity.TurbineVelocity.handleRequest(TurbineVelocity.java:143)
at org.apache.jetspeed.portal.controls.VelocityPortletControl.getContent(VelocityPortletControl.java:155)
at org.apache.jetspeed.util.template.JetspeedTool.getPane(JetspeedTool.java:154)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:260)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:207)
at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:250)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:94)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:271)
at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:128)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:271)
at org.apache.velocity.Template.merge(Template.java:296)
at org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:492)
at org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:461)
at org.apache.turbine.services.velocity.TurbineVelocityService.decodeRequest(TurbineVelocityService.java:494)
at org.apache.turbine.services.velocity.TurbineVelocityService.handleRequest(TurbineVelocityService.java:336)
at org.apache.turbine.services.velocity.TurbineVelocity.handleRequest(TurbineVelocity.java:143)
at org.apache.turbine.modules.screens.VelocityDirectScreen.buildTemplate(VelocityDirectScreen.java:123)
at org.apache.turbine.modules.screens.TemplateScreen.doBuild(TemplateScreen.java:130)
at org.apache.turbine.modules.Screen.build(Screen.java:99)
at org.apache.turbine.modules.ScreenLoader.eval(ScreenLoader.java:129)
at org.apache.turbine.util.template.TemplateScreen.toString(TemplateScreen.java:126)
at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:321)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:271)
at org.apache.velocity.Template.merge(Template.java:296)
at org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:492)
at org.apache.velocity.app.Velocity.mergeTemplate(Velocity.java:461)
at org.apache.turbine.services.velocity.TurbineVelocityService.decodeRequest(TurbineVelocityService.java:494)
at org.apache.turbine.services.velocity.TurbineVelocityService.handleRequest(TurbineVelocityService.java:336)
at org.apache.turbine.services.velocity.TurbineVelocity.handleRequest(TurbineVelocity.java:143)
at org.apache.turbine.modules.layouts.VelocityDirectLayout.doBuild(VelocityDirectLayout.java:106)
at org.apache.turbine.modules.Layout.build(Layout.java:91)
at org.apache.turbine.modules.LayoutLoader.exec(LayoutLoader.java:123)
at org.apache.turbine.modules.pages.DefaultPage.doBuild(DefaultPage.java:169)
at org.apache.turbine.modules.Page.build(Page.java:90)
at org.apache.turbine.modules.PageLoader.exec(PageLoader.java:123)
at org.apache.turbine.Turbine.doGet(Turbine.java:563)
at org.apache.turbine.Turbine.doPost(Turbine.java:658)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: