Hello, i'm trying to do a standard HQL query but I couldn't succeed...
I checked again and again the code and there is nothing different from the exemples i've read !
Could someone check and say what he thinks of it please ? ^^;
here is the code :
Code:
public List retrieveDataSets(String name) {
try {
Session session = SessionManager.getSession();
name="m12d.dat"; //test
String query =
"from datas.DataSet as ds "
+ "where ds.id = :name";
System.out.println("name: " + name);
System.out.println("query: " + query);
List datasets = session.find(query);
if (datasets.size() == 0) {
System.out.println("No parameters named " + name);
System.exit(0);
}
DataSet d = (DataSet) datasets.get(0);
System.out.println("Found parameter: " + d);
return datasets;
} catch (HibernateException e) {
throw new RuntimeException(e);
}
}
and the xml mapping og the bean
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="datas.DataSet" table="DATASETS">
<id name="id" type="string" unsaved-value="null">
<column name="dataset_filename" sql-type="char(32)" not-null="true" />
<generator class="assigned" />
</id>
...
...
...
</class>
</hibernate-mapping>
and the error :
Code:
name: m12d.dat
query: from datas.DataSet as ds where ds.id = :name
WARN - SQL Error: 0, SQLState: 07001
ERROR - No value specified for parameter 1
WARN - SQL Error: 0, SQLState: 07001
ERROR - No value specified for parameter 1
ERROR - Could not execute query
java.sql.SQLException: No value specified for parameter 1
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2201)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2154)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1452)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:205)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:800)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1536)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1513)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1505)
at utils.DataSetManager.retrieveDataSets(DataSetManager.java:101)
at actions.RetrieveAction.ListDataSets(RetrieveAction.java:111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.opensymphony.xwork.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:309)
at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:175)
at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:116)
at com.opensymphony.webwork.dispatcher.ServletDispatcher.serviceAction(ServletDispatcher.java:182)
at com.opensymphony.webwork.dispatcher.ServletDispatcher.service(ServletDispatcher.java:162)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at utils.SessionManager.doFilter(SessionManager.java:40)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
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:117)
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:793)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
at java.lang.Thread.run(Unknown Source)
I'm using hibernate 2, Webwork, tomcat and MySQL in my project