Try to search your question here, if you can't find : Ask Any Question Now ?

Using Variable in Spring @Query

HomeCategory: stackoverflowUsing Variable in Spring @Query
rupesh asked 2 weeks ago

I’m having an issue getting my variable to work in my @Query. Below is the code

@Query("SELECT new User(userId, userEmail, userForename, userSurname, userMiddleName) "
        + "FROM User "
        + "ORDER BY :orderBy DESC")
public List<User> findAllBy(@Param("orderBy") String orderBy);

I know the variable I want is being passed in properly. At the moment this is just returning all the results ordered by userId. If I hard code the value which is being passed into this function then it correctly returns the results ordered by userEmail (which is what is being passed in). Any suggestions would be great.

1 Answers
Best Answer
Amit answered 2 weeks ago
Your Answer

4 + 14 =

Popular Tags

WP Facebook Auto Publish Powered By :