Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

The ORDER BY clause seems to be ignored.

$
0
0
Hi,

I have a finder which looks like:
Code:

        @Query("SELECT a FROM Admin a ORDER BY a.lastname, a.firstname")
        public Page<Admin> findAll(Pageable page);

I use it as:
Code:

                Pageable pageRequest = new PageRequest(0, 10);
                Page<Admin> admins = adminRepository.findAll(pageRequest);

But the collection is not ordered as specified in the finder, and is returned in the order it was persisted.

Here is what the console log shows:
Quote:

select admin0_.id as id14_, admin0_.version as version14_, admin0_.address as address14_, admin0_.city
as city14_, admin0_.country as country14_, admin0_.email as email14_, admin0_.firstname as
firstname14_, admin0_.lastname as lastname14_, admin0_.login as login14_, admin0_.password
as password14_, admin0_.password_salt as password11_14_, admin0_.post_login_url as post12_14_,
admin0_.preference_admin as preference13_14_, admin0_.profile as profile14_, admin0_.super_admin
as super15_14_, admin0_.zip_code as zip16_14_ from admin admin0_ limit 10
Any clue ?

Kind Regards,

Stephane

Viewing all articles
Browse latest Browse all 297

Trending Articles