1 Reply Latest reply on Jan 9, 2004 6:07 PM by Anthony Law

    JBossQL ORDER BY as Param?

    Anthony Law Newbie

      Hi all,

      I'm trying to feed in params for my ejbfinder using JBossQL. It works for WHERE, LIMIT, and OFFSET, but the param for ORDER BY is completely ignored (no exceptions thrown anywhere) & MySQL returns the unsorted collection.

      Is it valid to do so? Or would I have to use another approach, maybe a dynamic-ql?

      Thanks.

      My jbosscmp-jdbc.xml entry:


      <![CDATA[Test finder]]>
      <query-method>
      <method-name>findByFilter</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      <method-param>java.lang.String</method-param>
      <method-param>java.lang.String</method-param>
      <method-param>java.lang.String</method-param>
      <method-param>java.lang.Integer</method-param>
      <method-param>java.lang.Integer</method-param>
      </method-params>
      </query-method>

      <declared-sql>
      <![CDATA[SMPEntity]]>
      <![CDATA[unitHardwareId LIKE {0} AND partitionName LIKE {1} AND state LIKE {2}]]>
      <![CDATA[{3}]]> <![CDATA[LIMIT {4} OFFSET {5}]]>
      </declared-sql>


      If I explicitly put in a column name, eg <![CDATA[PartitionName DESC]]>, then it'll work as expected.

      My JBoss log:

      2004-01-09 12:13:54,203 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCDeclaredSQLQuery.SMPEntity#findByFilter] Executing SQL: SELECT SMPEntity.Id, SMPEntity.UnitHardwareId FROM SMPEntity SMPEntity WHERE unitHardwareId LIKE ? AND partitionName LIKE ? AND state LIKE ? ORDER BY ? LIMIT ? OFFSET ?