|
From: Aapo L. <aap...@pr...> - 2002-10-11 14:57:32
|
I do not know why I cannot bind parameters to a named query.
Here is my query:
<query name="employees.default">
FROM e in class com.projectcast.persistent.employee.Employee
ORDER BY ?
</query>
And here is my code:
Query q = session.getNamedQuery("employees.default");
// this sort returns a string that is not a null.
q.setString(0, this.sort);
this.setEmployees(q.list());
Whatever I do I usually receive exceptions like this:
DEBUG [(hibernate.impl.SessionImpl)] Dont need to execute flush
DEBUG [(hibernate.query.QueryTranslator)] HQL:
FROM e in class com.projectcast.persistent.employee.Employee ORDER
BY ?
DEBUG [(hibernate.query.QueryTranslator)] SQL:
SELECT e.employee_id, e.firstname, e.lastname, e.contact_info_id
FROM employee e ORDER BY ?
DEBUG [(hibernate.impl.SessionFactoryImpl)] prepared statement get:
SELECT e.employee_id, e.firstname, e.lastname, e.contact_info_id
FROM employee e ORDER BY ?
Hibernate: SELECT e.employee_id, e.firstname, e.lastname,
e.contact_info_id
FROM employee e ORDER BY ?
DEBUG [(hibernate.impl.SessionFactoryImpl)] preparing statement
DEBUG [(hibernate.helpers.JDBCExceptionReporter)] SQL Exception
java.sql.SQLException: ERROR: Non-integer constant in ORDER BY
at
org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:94)
at org.postgresql.Connection.ExecSQL(Connection.java:398)
at org.postgresql.jdbc2.Statement.execute(Statement.java:130)
at
org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54)
at
org.postgresql.jdbc2.PreparedStatement.executeQuery(PreparedStatement.ja
va:99)
at cirrus.hibernate.loader.Loader.getResultSet(Loader.java:404)
at cirrus.hibernate.loader.Loader.doFind(Loader.java:115)
at cirrus.hibernate.loader.Loader.find(Loader.java:463)
at cirrus.hibernate.impl.SessionImpl.find(SessionImpl.java:1013)
at cirrus.hibernate.impl.QueryImpl.list(QueryImpl.java:73)
at
com.projectcast.web.actions.employee.EmployeeAction.doExecute(EmployeeAc
tion.java:49)
at webwork.action.ActionSupport.execute(ActionSupport.java:110)
at
webwork.dispatcher.ServletDispatcher.service(ServletDispatcher.java:261)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at
com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.ja
va:96)
at
com.caucho.server.http.Invocation.service(Invocation.java:312)
at
com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:221)
at
com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163
)
at com.caucho.server.TcpConnection.run(TcpConnection.java:137)
at java.lang.Thread.run(Thread.java:536)
WARN [(hibernate.helpers.JDBCExceptionReporter)] SQL Error: 0, SQLState:
null
ERROR [(hibernate.helpers.JDBCExceptionReporter)] ERROR: Non-integer
constant in ORDER BY
ERROR [(actions.employee.EmployeeAction)] java.sql.SQLException: ERROR:
Non-integer constant in ORDER BY
I have also tried using named parameters and tried to call
setParameter-method istead of setString.
Any ideas?
|