0

This is my NamedNativeQuery:

SELECT * FROM ( SELECT ROWNUMBER() OVER(ORDER BY CMSSCODE DESC) AS EL_ROWNM ,
CMSSCODE , CMSSDESC FROM tableName d WHERE CMSPCODE = ? ) a
WHERE a.EL_ROWNM    < ? and a.EL_ROWNM > ? 

I need to create in a dynamic way the order by, so my sql will be somthing like:

SELECT * FROM ( SELECT ROWNUMBER() OVER(ORDER BY ? ?) ....

so in the first parameter ? I will use the column name i get from the user and in the second parameter ? I will use ASC or DESC according to what I get from the user.

How is it possible to make a dynamic sorting in the NamedNativeQuery ?

Thank's In Advance.

user590586
  • 2,960
  • 16
  • 63
  • 96

1 Answers1

0

No it is not.

Use a dynamic query instead of a named query.

James
  • 17,965
  • 11
  • 91
  • 146