0 Replies Latest reply on Nov 8, 2002 8:51 AM by stekre

    ORDER by on non primary key

    stekre

      Hello,

      I would like to use the JBoss-QL ORDER BY STATEMENT.

      * @jboss.query
      * signature="java.util.Collection findAllOrderByCDesc()"
      * query="SELECT OBJECT(obj) from Table1 obj ORDER by obj.C DESC"

      The Table1 consists of three fields A, B, C.

      The fields A and B are in the primary key and my order by works if I use order by on A or B.

      But if I try to make an order by on field C which is not in the primary key I get the following error:

      Find failed: java.sql.SQLException: ORDER BY column (C) must be in SELECT list.

      How could I make an "order by" on a non primary key field.


      Thanks in advance for any help.

      Regards,
      Stefan.