is there a simple way to handle SQL injection in Hibernate HQL order by clause. Named params obviously doesn’t work for it.
EDIT:
Feel free to post your way of handling this problem. I want to see other people’s solutions and teach from them.
Thanks for any suggestions and solutions.
You could use the Hibernate criteria API instead of HQL.
The criteria API check that the order criterium refers a valid property.
if you try someting like that:
You will get an
QueryException: "could not resolve property this_ of de.test.DemoEntity"thrown by AbstractPropertyMapping.