1 Reply Latest reply on Oct 10, 2002 3:36 AM by Alexey Loubyansky

    ClassCastException when using JBossQL LIKE and parameters

    L T Newbie

      hi,

      I'm trying to write a JBossQL Query to use the LIKE operator with a parameter. I don't think my syntax is correct because when the Finder Method that uses this query is called, I get a ClassCastException. Here is my query:


      <query-method>
      <method-name>findByNameAndCity</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <jboss-ql><![CDATA[
      SELECT OBJECT(t)
      FROM table_name t
      WHERE (t.name LIKE ?1) AND
      (t.city LIKE ?2)
      ]]></jboss-ql>


      When I deploy the bean there are no error messages but as I mentioned, when the finder method that uses this query is called, I get a ClassCastException... the error message is pretty cryptic. I'm sure you all really love giant stacktraces but I can't make sense of it so I'll just cut and paste it:

      19:48:03,892 ERROR [STDERR] java.lang.ClassCastException: $Proxy707
      19:48:03,892 ERROR [STDERR] at org.apache.jsp.searchlistbasic$jsp._jspService(searchlistbasic$jsp.java:89)
      19:48:03,902 ERROR [STDERR] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
      19:48:03,902 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      19:48:03,902 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
      19:48:03,902 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
      19:48:03,902 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
      19:48:03,902 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      19:48:03,902 ERROR [STDERR] at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:344)
      19:48:03,902 ERROR [STDERR] at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:313)
      19:48:03,902 ERROR [STDERR] at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:554)
      19:48:03,902 ERROR [STDERR] at org.mortbay.jetty.servlet.WebApplicationHandler.handle(WebApplicationHandler.java:199)
      19:48:03,902 ERROR [STDERR] at org.mortbay.http.HttpContext.handle(HttpContext.java:1572)
      19:48:03,902 ERROR [STDERR] at org.mortbay.http.HttpContext.handle(HttpContext.java:1522)
      19:48:03,902 ERROR [STDERR] at org.mortbay.http.HttpServer.service(HttpServer.java:795)
      19:48:03,902 ERROR [STDERR] at org.jboss.jetty.Jetty.service(Jetty.java:531)
      19:48:03,902 ERROR [STDERR] at org.mortbay.http.HttpConnection.service(HttpConnection.java:784)
      19:48:03,912 ERROR [STDERR] at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:941)
      19:48:03,912 ERROR [STDERR] at org.mortbay.http.HttpConnection.handle(HttpConnection.java:799)
      19:48:03,912 ERROR [STDERR] at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:186)
      19:48:03,912 ERROR [STDERR] at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:322)
      19:48:03,912 ERROR [STDERR] at org.mortbay.util.ThreadPool$JobRunner.run(ThreadPool.java:716)
      19:48:03,912 ERROR [STDERR] at java.lang.Thread.run(Thread.java:484)

      Note that when I use the exact same query but replace 'LIKE' with '=' everything works fine.

      I'm using JBoss3.0.2 with Jetty/PostgreSQL. What do I need to change to get this to work?

      any help is greatly appreciated.